From owner-freebsd-questions Sat Aug 30 06:28:48 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id GAA17727 for questions-outgoing; Sat, 30 Aug 1997 06:28:48 -0700 (PDT) Received: from BIGFUN.vwcom.com ([151.197.101.21]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id GAA17722 for ; Sat, 30 Aug 1997 06:28:44 -0700 (PDT) Received: from WillsCreek.COM (gw.willscreek.com [151.197.101.46]) by BIGFUN.vwcom.com (8.8.6/8.8.6) with ESMTP id JAA08562 for ; Sat, 30 Aug 1997 09:23:47 -0400 (EDT) Received: from current.willscreek.com (root@current.willscreek.com [172.16.87.1]) by WillsCreek.COM (8.8.5/8.7.3) with ESMTP id JAA13757 for ; Sat, 30 Aug 1997 09:28:20 -0400 (EDT) Received: (from bmc@localhost) by current.willscreek.com (8.8.5/8.7.3) id JAA04754; Sat, 30 Aug 1997 09:28:20 -0400 (EDT) Date: Sat, 30 Aug 1997 09:28:20 -0400 (EDT) Message-Id: <199708301328.JAA04754@current.willscreek.com> From: Brian Clapper MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="zh3oQklXc94K4Oncr3b8iJWCMlJd6gHuC/WSj8q/" Content-Transfer-Encoding: 7bit To: questions@FreeBSD.ORG Subject: Re: Stripping ^M from llines? In-Reply-To: <49570184@toto.iv> X-Mailer: VM 6.23 under Emacs 19.34.1 Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk --zh3oQklXc94K4Oncr3b8iJWCMlJd6gHuC/WSj8q/ Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Robert Chalmers wrote: > Anyone got a handy program for stripping the ^M from text > lines in fbsd? Converting DOS files to UNIX (which is what I assume you're doing) is only a couple lines of perl. What's more, you don't need to recompile them if you want to take 'em someplace else (though you might need to edit the path to the perl binary). I've enclosed a dos2unix perl script and a unix2dos one. I've used them for years. ----- Brian Clapper, bmc@WillsCreek.COM, http://WWW.WillsCreek.COM/ Got Mole problems? Call Avogadro, 6.02 E23. --zh3oQklXc94K4Oncr3b8iJWCMlJd6gHuC/WSj8q/ Content-Type: text/plain Content-Description: dos2unix Content-Disposition: inline; filename="dos2unix" Content-Transfer-Encoding: 7bit #!/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). --zh3oQklXc94K4Oncr3b8iJWCMlJd6gHuC/WSj8q/ Content-Type: text/plain Content-Description: unix2dos Content-Disposition: inline; filename="unix2dos" Content-Transfer-Encoding: 7bit #!/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. --zh3oQklXc94K4Oncr3b8iJWCMlJd6gHuC/WSj8q/--