Re: automatically deleting ^M on text files
Olaf Meeuwissen <olaf@epkowa.co.jp> writes:
> t s a d i <ch4di@yahoo.com> writes:
>
> > i have a truckload oftext files (.html) that i need to edit and it
> > has the character "^M" all over it (caused when someone uploads a text
> > file and the ftp transfer is set to binary).
> >
> > does anyone know of a way to automate this ?
>
> At your shell prompt do:
>
> for file in *; do
> mv $file $file.old
> tr -d '\015' < $file.old > $file && rm $file.old
> done
>
> The '\015' is octal for CTRL-M (^M).
Well, you said you wanted to *delete* them (and that's what the above
faithfully does!), but I guess you'd like the keep the line breaks.
for file in *; do
mv $file $file.old
tr '\015' '\012' < $file.old > $file && rm $file.old
done
But then again, for HTML it shouldn't matter much ;-)
--
Olaf Meeuwissen Epson Kowa Corporation, Research and Development
Reply to: