开发者

Ignoring escape sequences and other characters in UNIX redirection [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
开发者_JS百科

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

Closed 11 months ago.

The community reviewed whether to reopen this question 11 months ago and left it closed:

Original close reason(s) were not resolved

Improve this question

I'm redirecting console output to a file, and getting [?25h and [?25l mixed in with my regular output. I've looked online and apparently they are the sequence characters for cnorm and civis, whatever those are. Is there any way to suppress these in the output?


One thing you might try is to set the TERM environment variable to something that doesn't support those features, for example with a Bash command like this:

env TERM=dumb yourcmd > yourfile

(Where yourcmd is the program whose output you'd like to redirect to output file yourfile)

For other shells, you might have to do something more like

setenv TERM dumb
yourcmd > yourfile


I ended up piping through sed. Jim's info is still very helpful, though. I used this command:

sed 's/\[?25[hl]//'

Incidentally, it catches [?25h and [?25l, but not when they're in succession ([?25h[?25l). Any suggestions for that?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜