> Resent-Cc: recipient list not shown:;@redhat.com
> Mbox-Line: From [EMAIL PROTECTED]  Wed Jun 17 15:08:18 1998
> Comments: Authenticated sender is <[EMAIL PROTECTED]>
> From: "Sim Robert" <[EMAIL PROTECTED]>
> Organization: AA
> Date: Wed, 17 Jun 1998 12:14:29 +0000
> Mime-Version: 1.0
> Content-Type: text/plain; charset=US-ASCII
> Content-Transfer-Encoding: 7BIT
> Reply-To: [EMAIL PROTECTED]
> X-Confirm-Reading-To: [EMAIL PROTECTED]
> Priority: normal
> X-Mailer: Pegasus Mail for Win32 (v2.54)
> Resent-From: [EMAIL PROTECTED]
> X-Mailing-List: <[EMAIL PROTECTED]> archive/latest/2119
> X-Loop: [EMAIL PROTECTED]
> Precedence: list
> Resent-Sender: [EMAIL PROTECTED]
> X-Url: http://www.redhat.com
> content-length: 480
> 
> Hi there,
> 
> After  I transferred some text files from DOS to Linux, I discovered 
> that there is a <cr> or ^M after each line. How do I remove those 
> <cr> quickly, instead of doing so one by one.
> 
> Thanks.

This question gets asked every once in a while - below is what I saved
from a reply from one time it was asked.  I don't remember whether I
tried it or not, but given my minimal knowledge of Perl, it looks
reasonable.  

Save the code below to a file called dos2unix and then make certain it
is executable (chmod 755 dos2unix) will do that if you don't know what
I'm talking about.  Then execute: dos2unix <filename>

I would save a copy of the file in a temporary file before doing this
in case it doesn't work since it overwrites the original file.

-Dave
 


#!/usr/local/bin/perl -pi
#
# Convert DOS text file to Unix file format.  Conversion is done in-place.
#
# Usage: dos2unix dosfile ...
print STDERR "Converting \"$ARGV\" ...\n" if (eof || ($. == 0));
s/\015$//;                   # strip ^M from end of line.
s/\032$//;                   # strip ^Z if we see it (which'll be at EOF).


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
         To unsubscribe: mail [EMAIL PROTECTED] with 
                       "unsubscribe" as the Subject.

Reply via email to