gpt4 book ai didi

Bash 脚本监听按键以继续

转载 作者:行者123 更新时间:2023-11-29 08:47:07 26 4
gpt4 key购买 nike

因此,我想编写一个包含一系列步骤的 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-nread 内置命令

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com