[CentOS] More awk help

Thu Jun 25 19:06:39 UTC 2009
Les Mikesell <lesmikesell at gmail.com>

David G. Miller wrote:
>
>> Hey guys,
>> Looking through my book and the web and I am not having any success
>> returning data from a search.
>>
>> I need to have awk search for a string and print the first field which
>> is no problem but now its returning two options as the input data has
>> changed. The change is reliable, I only want the first field if it ends
>> in a regex that I have, and I only want what that regex matches to be
>> printed. Is it possible to do this in a one liner so I don't need to
>> construct an awk script?
>>
>> I suppose I could pipe it into grep and cut but that's not very sexy :)
>>
>> Any ideas?
>>
>> Thanks!
>> jlc
>>
> 
> Being an old perl hacker I have to at least suggest doing whatever you're
> attempting in perl.  perl gives you much more powerful and flexible regular
> expression processing.  It also makes it really simple to pull out whatever
> matched within the RE.

This case is probably simple enough for sed, but in general I agree that 
if you need awk you probably might as well use perl which can also 
probably do a better job than the rest of the shell script that is 
likely surrounding this operation.

-- 
   Les Mikesell
    lesmikesell at gmail.com