How to delete non-ASCII chars in file

Mark B. mkbucc at gmail.com
Fri Sep 5 14:39:06 UTC 2008


I have a text file that includes some non-ASCII characters
For example, opening the file in vi shows lines like this:

 'easth_0.541716776378'      0   \xe2\x80\x98dire'       2

Is there a command-line tool I can use to delete these
characters?  I tried:

    cat f | tr -cd [:print:]

but this removes the newlines.

I also tried

   cat f | sed "s/[^:print:]//g"

but it didn't remove the characters.

Thanks,

m


More information about the freebsd-questions mailing list