bash - 如何在继续之前暂停我的 shell 脚本一秒钟?

标签 bash shell unix

我只找到了如何等待用户输入。但是,我只想暂停一下,这样我的 while true 就不会使我的计算机崩溃。

我尝试了 pause(1),但它显示 -bash: syntax error near unexpected token '1'。怎么做到的?

最佳答案

使用 sleep 命令。

例子:

sleep .5 # Waits 0.5 second.
sleep 5  # Waits 5 seconds.
sleep 5s # Waits 5 seconds.
sleep 5m # Waits 5 minutes.
sleep 5h # Waits 5 hours.
sleep 5d # Waits 5 days.

指定时间单位时也可以使用小数;例如休眠 1.5s

关于bash - 如何在继续之前暂停我的 shell 脚本一秒钟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21620406/

相关文章:

macos - Bash 别名给出的结果与仅运行命令不同

regex - php脚本中的Bash命令,根据特定列的值获取文件的某些行

unix - 如何允许 chroot-ed 用户 SSH 和 SFTP 访问

linux - 进程名称长度的最大允许限制是多少?

bash - 带和不带关键字的 shell 函数定义

python - 我如何使用 Mechanize 接受和发送 cookie?

node.js - nodejs 失败,但即使我设置了 -e bash 也不会停止

function - C shell 如何将多个命令放在一个别名中?

shell - 如何在成功完成脚本的情况下从具有返回值 1 的 shell 脚本返回

python - 如何在 Python 中对 Active Directory 服务器进行两阶段身份验证?