sed/awk, instead of Perl

Anton Shterenlikht mexas at bristol.ac.uk
Thu Aug 21 13:33:59 UTC 2008


On Thu, Aug 21, 2008 at 09:17:43AM -0400, Steve Bertrand wrote:
> Wojciech Puchar wrote:
> >>
> >> Try the following:
> >>
> >>
> >> cat t.txt | awk -F\t '{split($1, arr, "."); printf("%s_%s@%s\n", arr[
> >> 1], arr[2], $2);}'

a shorter way:

sed s/\\./_/g <inputfile> | awk '{print $1 "@example.com"}' > <outputfile>

-- 
Anton Shterenlikht
Room 2.6, Queen's Building
Mech Eng Dept
Bristol University
University Walk, Bristol BS8 1TR, UK
Tel: +44 (0)117 928 8233 
Fax: +44 (0)117 929 4423


More information about the freebsd-questions mailing list