eliminate character with sed

Warren Block wblock at wonkity.com
Sun May 20 17:41:27 UTC 2012

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


More information about the freebsd-questions mailing list