I have a command that produces output in color, and I would like to pipe it into a file with the color codes stripped out. Is there a command that works like cat except that it strips color codes? I plan to do something like this:$ command-that-produces-colored-output | stripcolorcodes > outfile
Program that passes STDIN to STDOUT with color codes stripped?
colors;pipe;filter
You'd think there'd be a utility for that, but I couldn't find it.  However, this Perl one-liner should do the trick:perl -pe 's/\e\[?.*?[\@-~]//g'Example:$ command-that-produces-colored-output | perl -pe 's/\e\[?.*?[\@-~]//g' > outfileOr, if you want a script you can save as stripcolorcodes:#! /usr/bin/perluse strict;use warnings;while (<>) {  s/\e\[?.*?[\@-~]//g; # Strip ANSI escape codes  print;}If you want to strip only color codes, and leave any other ANSI codes (like cursor movement) alone, uses/\e\[[\d;]*m//g;instead of the substitution I used above (which removes all ANSI escape codes).