SUMMARY: remove ^M from a file

From: Vincent.D'Antonio@bisys.com
Date: Fri May 10 2002 - 16:07:48 EDT


WOW, I received responds faster then my own mail was sent to me ( which I
am still waiting to see ). Here are some replies.

thanks to:

Tripathi, Ashish cat file | col -b > new file name

Phil Farrell The simplest way I know is to use "tr" to delete the CTRL-M
characters,
using the octal code from the ASCII chart to specify it, for example,

tr -d '\015' < original_file > new_fixed_copy

Ballowe, Charles cat <file> | sed -e 's/Ctrl-vCtrl-m//' >> <file>.new ;
mv <file>.new <file>

Paul A Sand I use:

     perl -pi -e 's/\r//g;' filename

(Removes them everywhere)

If you want them replaced with Unix newlines:

     perl -pi -e 's/\r/\n/g;' filename

I think there's probably a way to do it with sed too.

Kurt A. Ludwig there should be a utility called dos2unix that will take
care of it.

Peter Mittermayer, and Xavier Mertens sed "s/^M$//g" <infile >outfile

John Venier # tr -d '\r' < oldfile > newfile

?

Warning: this does not limit the removal of the ^M to the ends of
lines; it removes all of them.

plus many more, I thank all who replied.

thanks again
Vince

---------------------------------------------------------------------------------------------------------

Vincent D'Antonio
Unix Systems Engineer
Bisys Retirement Services
200 Dryden Road
Dresher, PA 19025

phone: 215-542-2555
fax: 215-542-2603
e-mail: Vincent.D'Antonio@bisys.com



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:48:40 EDT