sed/awk, instead of Perl
Steve Bertrand
steve at ibctech.ca
Thu Aug 21 13:10:22 UTC 2008
Matthias Apitz wrote:
> El día Thursday, August 21, 2008 a las 05:54:29AM -0700, Joseph Olatt escribió:
>
>> Try the following:
>>
>>
>> cat t.txt | awk -F\t '{split($1, arr, "."); printf("%s_%s@%s\n", arr[
>> 1], arr[2], $2);}'
>>
>> where t.txt:
>> john.doe example.com
>
> Despite of the magic awk(1) or while-loops: this is all UUOC Award;
> http://en.wikipedia.org/wiki/Cat_(Unix)#Useless_use_of_cat
Yeah, yeah :)
I know that:
# grep username /var/log/radius.log
...is much, much better than:
# cat /var/log/radius.log | grep username
...but that is just semantics, relative to the intent and purpose of
this excercise.
Besides, our mail servers don't do enough work, so using cat in the
wrong context when modifying tens of thousands of lines in a file is
good exercise for my boxes ;)
Steve
More information about the freebsd-questions
mailing list