Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我将此行添加到脚本的末尾,它工作正常。但我想在脚本之间添加这一行&如果我按 n 那么它应该继续执行进一步的脚本直到结束:
#!/bin/bash echo -n 'want to run Gather [y n]?' read response [ "$response" = "y" ] || exit; cd /var/tmp/ ./gather.sh
目前,只要 $response 不是“y”,您就调用 exit:
[ "$response" = "y" ] || exit;
要根据条件选择性地执行某些语句,请使用 if 语句:
if [ "$response" == "y" ] ; then cd /var/tmp/ ./gather.sh fi echo "continuing ..."
即使没有输入“y”,这将继续回显“继续...”。