stripping color control characters from lssam output.
Posted by peeterjoot on March 17, 2010
There’s probably a billion ways to do this, but here’s one that appears to work. If you have TSA command output that has been collected by a somebody who did not use the –nocolor option.
perl -p -e 's/\x1b\[\d+m//g;' < lssamBEFORE.out
The \x1b is the ESC character. This says to remove that ESC followed by a ‘[‘ character, then 1 or more digits and the character ‘m’, and do it for all lines.