Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Dec 2002 06:05:59 -0700 (MST)
From:      Warren Block <wblock@wonkity.com>
To:        D J Hawkey Jr <hawkeyd@visi.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: tool/method to convert DOS line endings to UNIX line endings
Message-ID:  <Pine.BSF.4.21.0212040557280.13865-100000@wonkity.com>
In-Reply-To: <200212040153.gB41rF154346@sheol.localdomain>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 3 Dec 2002, D J Hawkey Jr wrote:

> In article <Pine.BSF.4.21.0212031550360.12062-100000_wonkity.com@ns.sol.net>,
> 	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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0212040557280.13865-100000>