From owner-freebsd-questions Wed Dec 4 6: 1: 9 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E7BF037B401 for ; Wed, 4 Dec 2002 06:01:07 -0800 (PST) Received: from bran.mc.mpls.visi.com (bran.mc.mpls.visi.com [208.42.156.103]) by mx1.FreeBSD.org (Postfix) with ESMTP id 67D6143ED4 for ; Wed, 4 Dec 2002 06:01:06 -0800 (PST) (envelope-from hawkeyd@visi.com) Received: from sheol.localdomain (hawkeyd-fw.dsl.visi.com [208.42.101.193]) by bran.mc.mpls.visi.com (Postfix) with ESMTP id 902754BB9; Wed, 4 Dec 2002 08:01:05 -0600 (CST) Received: (from hawkeyd@localhost) by sheol.localdomain (8.11.6/8.11.6) id gB4E14R56500; Wed, 4 Dec 2002 08:01:04 -0600 (CST) (envelope-from hawkeyd) Date: Wed, 4 Dec 2002 08:01:04 -0600 From: D J Hawkey Jr To: Warren Block Cc: freebsd-questions@freebsd.org Subject: Re: tool/method to convert DOS line endings to UNIX line endings Message-ID: <20021204080104.A56240@sheol.localdomain> Reply-To: hawkeyd@visi.com References: <200212040153.gB41rF154346@sheol.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from wblock@wonkity.com on Wed, Dec 04, 2002 at 06:05:59AM -0700 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Dec 04, at 06:05 AM, Warren Block wrote: > > On Tue, 3 Dec 2002, D J Hawkey Jr wrote: > > > In article , > > wblock@wonkity.com writes: > > > It's a bit easier if you let Perl do the heavy lifting: > > > > > > perl -pi -e 's/\r//g' file-to-convert > > > > Even easier (and "lighter") if you ditch the perl: > > sed -e 's/\r//g' input >output > > Unfortunately, that doesn't work because BSD sed doesn't understand \r > (it should, IMO, but it doesn't). It can work if you put an actual CR > in there... Ack. Looks like you're right, and I agree with you. If "[2addr]l" can output '\r', "[2addr]s/regex/repl/flags" ought to understand "\r". I have to wonder how many times I may have been bitten by this mis-feature. ;-, This'll work though: sed -e 's/[[:cntrl:]]$//g' > > I like the tr(1) conversion too, but I always seem to think in terms of > > sed(1) and awk(1). And if that sed(1) solution is still "too loose", the tr(1) solution reduces "[[:cntrl:]]" to just the CR character. > I've been making an effort to use Perl for this type of thing, because > it usually saves me time. When a shell script turns out later to need > strong string processing or any of the other stuff that Perl is good at > but is non-trivial in a shell script, I don't need to rewrite it if it's > already in Perl. And many scripts that are trivial in Perl (like the > one above) can be non-trivial for csh or sh. Agreed, in principle, but with caveats. Perl isn't available in single-user mode without mounting /usr (or /usr/local on other OSes), and IIRC, perl won't be in the base for FreeBSD 5.0 (something about "miniperl"?). Outside of FreeBSD, perl may not be available at all. I try to use the tools of a base installation of any OS for these "quick-n-dirty" things, if just to know that I can. And I guess there's enough frugalness(?) in me to opt for the lighter weight tool when it's all that's needed. Nice to have so many options, though! > -Warren Block * Rapid City, South Dakota USA See Ya, Dave -- ______________________ ______________________ \__________________ \ D. J. HAWKEY JR. / __________________/ \________________/\ hawkeyd@visi.com /\________________/ http://www.visi.com/~hawkeyd/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message