문제

Some programs makes beautiful progressbars and stuff using ANSI escape sequences. That's nice.

What's not nice though is that if i put the output of that kind of program into a file and then try to view it it's filled with strange escape sequences.

Is there a way to strip away all the ANSI codes while logging?

I usually log the output of a script this way:

./script >> /tmp/output.log
도움이 되었습니까?

해결책

Try:

$ TERM=dumb ./script >> /tmp/output.log

If that doesn't work, it's because the ANSI codes have been hard-coded into the script, so there is no easy way to remove them. If it does, it's because it's doing the right thing, delegating things like pretty output to libncurses or similar, so that when you change the TERM variable, the library no longer sends those codes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top