SUMMARY: remove ^M from a file

From: <Vincent.D'Antonio_at_bisys.com>
Date: Fri, 10 May 2002 16:07:48 -0400

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_at_bisys.com
Received on Fri May 10 2002 - 20:12:27 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:43 NZDT