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

William Sutton via TriLUG trilug at trilug.org
Tue Aug 18 15:40:40 EDT 2015


PCRE (Perl Compatible Regular Expressions), which is what the -P option 
implies, isn't compatible with Perl.  See, for example,

https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions

"The name is misleading, because PCRE and Perl each have capabilities not 
shared by the other."

William Sutton

On Tue, 18 Aug 2015, Kevin Otte via TriLUG wrote:

> 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
> -- 
> This message was sent to: William <william at trilug.org>
> 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/william%40trilug.org
> Welcome to TriLUG: http://trilug.org/welcome


More information about the TriLUG mailing list