Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 May 2012 11:41:23 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        Polytropon <freebsd@edvax.de>
Cc:        Tim Dunphy <bluethundr@gmail.com>, freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: eliminate character with sed
Message-ID:  <alpine.BSF.2.00.1205201128050.97848@wonkity.com>
In-Reply-To: <20120520182245.b04d681f.freebsd@edvax.de>
References:  <CAOZy0enEPQNFrJv-xZ-H5_18_r5rvjHQQCeFQT6x26TGTf0c0g@mail.gmail.com> <20120520182245.b04d681f.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 20 May 2012, Polytropon wrote:

> Regarding the use of "sed": I'm not sure if it's possible
> to do something like
>
> 	% sed -i '.bak' 's/\r//g' config.php
>
> because I assume (not tested!) that it's not possible to
> put in escape sequences like that. But try for yourself
> and surprise me. :-)

A traditional way of stripping CRs is with col(1):

   % col < config.php > config.php-lfonly

sed almost goes out of its way to make the most useful escapes 
unavailable, or at least unavailable where you need them.  Perl makes it 
all available and can be used as a sed replacement:

   % perl -i.bak -pe 's/\r//g' config.php

(Tested.)



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