From owner-freebsd-questions Sun Jan 10 23:50:39 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA23829 for freebsd-questions-outgoing; Sun, 10 Jan 1999 23:50:39 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from inet.chip-web.com (c1003518-a.plstn1.sfba.home.com [24.1.82.47]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id XAA23823 for ; Sun, 10 Jan 1999 23:50:36 -0800 (PST) (envelope-from ludwigp@bigfoot.com) Received: (qmail 23115 invoked from network); 11 Jan 1999 07:50:03 -0000 Received: from speedy.chip-web.com (HELO speedy) (172.16.1.1) by inet.chip-web.com with SMTP; 11 Jan 1999 07:50:03 -0000 Message-Id: <4.1.19990110234101.00a91500@mail-r> X-Sender: ludwigp2@mail-r X-Mailer: QUALCOMM Windows Eudora Pro Version 4.1 Date: Sun, 10 Jan 1999 23:49:42 -0800 To: "Robert Luce" , "charon@freethought.org" From: Ludwig Pummer Subject: Re: replacing ^M in vi Cc: "freebsd-questions@freebsd.org" In-Reply-To: <199901110711.XAA18400@hub.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Just some further info... if you were to do a hex dump ("hd") of the text file, you would see at the end of each line an "0d 0a", that's an ASCII 13 followed by an ASCII 10, aka CRLF. BTW, two simple perl scripts which were posted on this list a long time ago (sometime before Oct. 5, 1997) take care of CRLF conversions for you: ---unix2dos--- #!/usr/bin/perl -pi # # Convert Unix text file to DOS file format. Conversion is done in-place. # # Usage: unix2dos unixfile ... print STDERR "Converting \"$ARGV\" ...\n" if (eof || ($. == 0)); s/$/\015/; # tack on ^M s/\n/\n\032/ if (eof); # DOS ^Z at end of file. ---dos2unix--- #!/usr/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). At 11:10 PM 1/10/99 , Robert Luce wrote: >%s///g > > means press control-v > means hit the enter key or press control-m > >On Sun, 10 Jan 1999 22:59:10 -0800, charon@freethought.org wrote: > >>Whenever I save a plain text file in WinNT and open it in FreeBSD, at the >>end of every line is a "^M". How do I get rid of these? I tried writing a >>little C++ program to copy all text except "^M" to another file, but it >>doesn't work because C++ treats the ^ and the M as different characters, >>whereas vi treats them as _one_ character. After searching the mailing >>list archives, I came up with the syntax ":%s/stuff/other stuff/g" as the >>oh-so-intuitive replace command in vi, and I tried it, but to no avail (it >>says "no match found"). Any suggestions? Thanks, --Ludwig Pummer ( ludwigp@bigfoot.com ) ICQ UIN: 692441 ( ludwigp@email.com ) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message