我有以下代码:
echo "some output"
while true ; do
echo "running"
./call-me.sh
echo "all done. ctrl+c to exit"
sleep 5
done
我想让用户可以选择退出脚本,而不用担心call-me.sh
失败。这个脚本的结果类似于:
some output
running
all done. ctrl+c to exit
running
all done. ctrl+c to exit
running
all done. ctrl+c to exit
running
all done. ctrl+c to exit
running
all done. ctrl+c to exit
running
all done. ctrl+c to exit
^C
我只想在输出中显示一行,如果call-me.sh
正在运行,则显示running
,或者显示all done. ctrl+c to exit
。我不想使用clear
,因为这是脚本的一部分,我想保留其余的输出。总之,我想用新的一行编辑最后一行输出。因此输出将是:
some output
running
或
some output
all done. ctrl+c to exit
想法?
我将添加一个";停止文件";。如果退出,脚本将删除它并退出。
更改为以下内容,看看这是否有效
test.sh有以下代码
while true ; do
clear
./call-me.sh
echo "