On removing ^M

regisr regisr at pobox.com
Sun May 8 13:35:52 PDT 2005


On Sun, 08 May 2005 12:53:06 -0700

> > tr -d "\r" < input-file > output-file
> Or:
> perl -pi -e 's/\015//' *.c
> which will edit all .c files in place, or:
> perl -pi.bak -e's/\015//' *.c

(I forget to add a for or foreach line!)

If there is a large number of files (i.e. if the command is too
long - error: "Argument list too long")

try something like:

find -X . -type f -print | xargs -L 1  perl -pi.bak -e's/\015//'

Don't forget to do a backup copy of your original files!
If filenames should be protected (enclosed in "" or '' ) the -X find
option complains and skip them.


-- 
<regisr>  


More information about the freebsd-questions mailing list