From owner-freebsd-questions Wed Dec 4 5: 6: 2 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 E979C37B401 for ; Wed, 4 Dec 2002 05:06:00 -0800 (PST) Received: from wonkity.com (wonkity.com [63.93.4.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 508C343E88 for ; Wed, 4 Dec 2002 05:06:00 -0800 (PST) (envelope-from wblock@wonkity.com) Received: from wonkity.com (localhost.wonkity.com [127.0.0.1]) by wonkity.com (8.12.1/8.11.6) with ESMTP id gB4D5xuF013903; Wed, 4 Dec 2002 06:05:59 -0700 (MST) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.12.1/8.12.1/Submit) with ESMTP id gB4D5xAC013900; Wed, 4 Dec 2002 06:05:59 -0700 (MST)?g (envelope-from wblock@wonkity.com) Date: Wed, 4 Dec 2002 06:05:59 -0700 (MST) From: Warren Block To: D J Hawkey Jr Cc: freebsd-questions@freebsd.org Subject: Re: tool/method to convert DOS line endings to UNIX line endings In-Reply-To: <200212040153.gB41rF154346@sheol.localdomain> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 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, and there's the sed-inplace stuff to eliminate the extra file and redirection, but... see below. > I like the tr(1) conversion too, but I always seem to think in terms of > sed(1) and awk(1). 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. -Warren Block * Rapid City, South Dakota USA To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message