Remove ^M Characters from Vi


In VI:
:g/^M/s/// (the ctrl-m has to be entered with the key strokes “ctrl-v followed by ctrl-m”.

Using SED:
sed ‘s(ctrl v ctrl m)g//g’ old.file > new.file

And with ‘tr’ :
tr -d '\r' < inputfile > outputfile

Using the octal representatiion of ^M. The following gets rid of control-M as well as control-Z (DOS eof marker):
tr -d ‘1532’ < file

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s