[Techtalk] get rid of "^M" in a file

Gebhard Dettmar gebhard.dettmar at student.hu-berlin.de
Sat Jun 18 08:39:41 EST 2005


On Thursday 16 June 2005 08:17, James Allen wrote:
> From within vi:
> :1,$ s'^M''g
>
> To put ^M in the command line:
> Hold down on the CTRL key and press v and m.
>
> To accomplish the same task from the command line without opening the
> file:
>
> vi -c "%s/^M//g" -c "wq" file_name
Great. Didn't know this yet
> For multiple files:
>
> for f in /path/to/files/*; do vi -c "%s/^M//g" -c "wq" $f; done
or find /path/to/files/* -exec perl -pi -e 's/\r\n/\n/' {} \;
but make sure there are no binaries in it. Maybe /path/to/file/*txt or 
*html is better
Regards gebhard


More information about the Techtalk mailing list