消除对Linux终端产出 [英] erasing terminal output on linux

查看:104
本文介绍了消除对Linux终端产出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写这将有一个状态栏,就像一个wget的命令行程序。

I was writing a command line program which will have a status bar, much like wget.

我现在面临的主要问题是:我怎么删除我已经送入标准输出/标准错误

The main problem I'm facing is: how do I delete what I've already sent into stdout/stderr?

我有主意:用退格字符\\ b'和抹去我送的输出。那是最好的办法?它是唯一的出路?有没有更好的办法?

I had on idea: use the backspace char '\b' and erase the output I've sent. Is that the best way? Is it the only way? Is there a better way?

PS:我不想使用像ncurses的东西。平原旧的C吧。

PS: I don't want to use anything like ncurses. Plain old C please.

感谢

编辑:

我可以还和/或降低?例如:我有10行输出,我想改变从 3号线做ABC ABC:完成。我该怎么做?

Can I also go up and/or down? Example: I have 10 lines of output, I want to change the 3rd line from Doing ABC to ABC: Done. How can I do that?

此外,任何人都可以发布关于什么VT102字符是更多的细节?它有什么功能?请张贴在这个良好的联系,如果您有任何。

Also, can anyone post more details about what VT102 characters are? What are its capabilities? Please post good links on this if you have any.

感谢

推荐答案

使用'\\ R'返回行的开头,并可能重写整个行。

Use '\r' to return to the beginning of the line and possibly rewrite the whole line.

寻找VT102控制序列 - 这些都是字符序列ESC ......来控制你的终端

Look for VT102 control sequences - these are character sequences ESC ... to control your terminal.

这篇关于消除对Linux终端产出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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