At Mon, 13 Jan 2003 11:08:38 +1000, Scott Ragen wrote:
> Is there a way to remove all control characters from a file?
> eg: I have a file that has characters: ^M, ^@, ^L, etc which need to be 
> removed, but the file also contains: � and alike that need to stay.
> How could I accomplish this?

not having a good dataset handy, its a bit hard for me to test.  but
one of these might do (they filter stdin to stdout):

# this might need � to be a valid char in your current locale
 tr -d '[:cntrl:]'

 tr -d '\000-\008\013-\037'

# ditto with the locale thing
 perl -Mlocale -pe 's/[[:cntrl:]]//g'


It might also help if you told me what encoding the input is in
(I think I'm assuming latin-1 here).

-- 
 - Gus
--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to