[TriLUG] awk question - or something better if you have it

Kevin Otte via TriLUG trilug at trilug.org
Tue Aug 18 14:34:04 EDT 2015


Well, grep has Perl style regex:

kjotte at mystic:~$ nginx -V 2>&1 | grep -oP -- '--conf-path=\K([^\s]+)'
/etc/nginx/nginx.conf

I don't claim to fully understand what I just did as regex was never my
strong suit. I conglomerated from:

http://unix.stackexchange.com/questions/13466/can-grep-output-only-specified-groupings-that-match

http://stackoverflow.com/questions/1400431/regular-expression-match-any-word-until-first-space


On 08/18/2015 02:17 PM, Michael Peters wrote:
> I know Perl has a reputation for being unreadable, but that awk code
> is much worse IMO :)
> 
> On Tue, Aug 18, 2015 at 1:38 PM, Dewey Hylton via TriLUG
> <trilug at trilug.org> wrote:
>> On Aug 18, 2015, at 1:30 PM, Kevin Otte nivex at nivex.net wrote:
>>
>>> This what you mean?
>>>
>>> kjotte at mystic:~$ nginx -V 2>&1 | awk 'BEGIN {RS=" ";FS="=";} $1 ~
>>> /conf-path/{print $2}'
>>> /etc/nginx/nginx.conf
>>
>> YES! that is exactly what i was after; i think i need to dust off the
>> old oreilly book ... this is much simpler than what i had envisioned
>> being necessary for an awk solution ...
>>
>> thanks!
>> --
>> This message was sent to: Michael Peters <michael00peters at gmail.com>
>> To unsubscribe, send a blank message to trilug-leave at trilug.org from that address.
>> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
>> Unsubscribe or edit options on the web  : http://www.trilug.org/mailman/options/trilug/michael00peters%40gmail.com
>> Welcome to TriLUG: http://trilug.org/welcome


More information about the TriLUG mailing list