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

James Allen jamesfallen at gmail.com
Thu Jun 16 16:17:07 EST 2005


>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

For multiple files:

for f in /path/to/files/*; do vi -c "%s/^M//g" -c "wq" $f; done


More information about the Techtalk mailing list