How to get rid of escape sequences in text file

Deron Meranda deron.meranda at gmail.com
Mon Mar 21 05:00:52 UTC 2005


On Sun, 20 Mar 2005 15:52:37 -0800, Gordon Charrick <gordonmc at cox.net> wrote:
> I'm looking for a way to convert a file with control characters that do
> things like bold, underline, etc into a plain ordinary text file. I
> haven't figured out how to do it yet. Anyone have a nice simple
> solution? An example of a file with this problem is
> /usr/share/doc/pam-0.77/txts/pam.txt

The col(1) and colcrt(1) commands are sometimes useful for this sort
of thing.  But they'll leave parts of escape sequences behind for those
sequences they don't understand.

This sed command seems to do the trick, at least for your mentioned file:

   sed -e 's/\o033\o133[0-9][0-9]*m//g'  <infile >outfile

-- 
Deron Meranda




More information about the fedora-list mailing list