sed/awk, instead of Perl

Steve Bertrand steve at
Fri Aug 22 12:26:20 UTC 2008

Oliver Fromme wrote:
> Walt Pawley wrote:

>  > I guess getting old, nearly blind and mind numbing close to
>  > brain dead is better than the alternative. Try this (sooner or
>  > later I've got to get it right)...
>  > 
>  > perl -pe 's/(.*?)\.(.*)\t.*/$1_$2\' input_file > output_file
>  > 

> I think your attempts show very well why Steve wanted to
> avoid perl.  :-)

LOL...actually, I use Perl for almost everything, but I don't think I've 
ever used it on the command line.

For things that I need to do on a repeated basis where most of the 
variables are consistent, or for automation tasks I always use Perl.

>  - tr, sed, awk etc. are part of the FreeBSD base system,
>    while perl is not.

This is another reason. I do have a couple of machines that do not have 
Perl installed on them, so when I need to do a quick change to multiple 
entries in a file, I'm quite used to using sed/awk. It had just been a 
while since I've used it to make more than one change per entry (well, 
since my tcpdump file example).

Oliver posted yesterday three examples using sed, awk and tr.

The one that I will stick with and will not have any difficulty 
remembering was this one:

# tr '.\t' '_@' | sed 's/@.*/'

I am the most familiar with that one as I use sed on almost an every day 

I appreciate all of the feedback. There have been some excellent methods 
that have been very wide ranging. As the saying goes, TIMTOWTDI ;)


More information about the freebsd-questions mailing list