因此,我想编写一个包含一系列步骤的 bash 脚本,并将其标识为“task#”。然而,每一步都只是完成并且可以运行到用户想要的时间。
Do task1
if keypressed stop task1 and move on #this is the part I need help with. There can be up to 10 of these move on steps.
Do task2
...
kina 喜欢 top;它一直在做一些事情,直到你按 q 到相当,但是,我想继续下一件事
最佳答案
您可以使用带有选项-t
和-n
的read
内置命令
while :
do
# TASK 1
date
read -t 1 -n 1 key
if [[ $key = q ]]
then
break
fi
done
# TASK 2
date +%s
关于Bash 脚本监听按键以继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9731281/