Thursday, October 15, 2009

Removing chars from files in a directory

Some files got generated with symbols like the 'tm' symbol and the system consuming those files can't handle those characters... so we had to remove them.

To identify them:
find . | xargs perl -ne 'print if /[\176-\512]/' | perl -ne 'print "$1\n" if /(\d+),.*/'

To remove the "special" characters:
find . -type f -print0 | xargs -0 perl -p -i -e 's/[\176-\512]//g'

quick and dirty!

No comments: