:g/^M/s/// (the ctrl-m has to be entered with the key strokes “ctrl-v followed by ctrl-m”.
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