cat something | perl -le 'while (<>) {chomp; s/[\000-\037]\[(\d|;)+m//g; print ($_) };' #### # sth; sth; { s/[\000-\037]\[(\d|;)+m//g; } # sth else;