【发布时间】:2013-02-09 14:38:54
【问题描述】:
我目前正在编写一个 bash 脚本来自动执行任务。在我的脚本中,我希望它在执行任务时显示进度消息。
例如:
user@ubuntu:~$ 配置一些东西
->
配置一些东西。
->
配置一些东西..
->
配置一些东西...
->
配置一些东西......完成
所有进度消息都应该出现在同一行。 以下是我目前的解决方法:
echo -n "Configure something "
exec "configure something 2>&1 /dev/null"
//pseudo code for progress message
echo -n "." and sleep 1 if the previous exec of configure something not done
echo " done" if exec of the command finished successfully
echo " failed" otherwise
exec 会等待命令完成,然后再继续执行脚本行吗?
如果是这样,那么我如何在执行配置某事的同时回显消息?
我如何知道 exec 何时完成上一个命令并返回 true?使用$? ?
【问题讨论】:
标签: bash