继续同线路输出 [英] Continue output on same line

查看:74
本文介绍了继续同线路输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要通过打印[OK]在当一个任务完成的最后一行的末尾做一个奇特的效果。

Want to do a fancy effect by printing [OK] at the end of the last line when a task is finished.

得到这个:

echo "$0: Starting backup process in '$backupdir'... " 
sleep 3
echo '[OK]'

我尝试不同的东西在第一回波的结束,在第二个像 \\ r \\年初ç \\ ,GOOGLE了它......没有好处的。

I tried different things at the end of the first echo, at the beginning of the second like \r, \c, \, Googled it... No good.

我希望它输出这样的:

./ backup.sh:启动备份过程在'/备份'...

...和3秒后,添加 [OK]

... And 3 sec later, add the [OK]:

./ backup.sh:启动备份过程在'/备份'... [OK]

谢谢,

推荐答案

使用 -n 选项在最后跳过打印换行符。在 更多参考回波文档

Use the -n option to skip printing newline at the end. More reference at echo docs.

所以你可以做这样的事情:

So you could do something like this:

echo -n "$0: Starting backup process in '$backupdir'... " 

这篇关于继续同线路输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆