Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got a file that's full of VT100 color codes, which is making it hard to search. Is there a unix utility that can strip those out so I'm left with plain text?

share|improve this question

4 Answers 4

This might help:

esc=$'\033'
sed "s/${esc}[^m]*m//g" inputfile
share|improve this answer

the strings command possibly!

share|improve this answer
    
I tried that, it leaves a bunch of [01;34m strings –  jes5199 Jun 23 '10 at 19:12
    
ok then pipe it to sed with the appropriate edits and yes there's got to be a better way. –  tony roth Jun 23 '10 at 19:18

Try catting it through col -b

cat file | col -b

This works for stripping the troff/nroff formatting for man pages. Worth a try.

If that doesn't work, there's quite a good thread on perlmonks:

http://www.perlmonks.org/?node_id=132997

share|improve this answer

Trying to cleanup the output of a script run?

I remember there was a script that did exactly this on some system I used to have access to... I think it was the University of Waterloo Math Department's Unix machines.

But I think some clever bastard there wrote it a while ago. Find a friend still at UW :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.