sed/awk, instead of Perl
Steve Bertrand
steve at ibctech.ca
Thu Aug 21 13:41:29 UTC 2008
Anton Shterenlikht wrote:
> 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>
Nice! Although Joseph's line works perfectly, your sed method is much
more inline with the way I'm used to using things, and I'll remember it
easier without having to review notes next time ;)
Thanks,
Steve
More information about the freebsd-questions
mailing list