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

Dewey Hylton via TriLUG trilug at trilug.org
Tue Aug 18 13:34:42 EDT 2015


On Aug 18, 2015, at 1:12 PM, Brian Gerard bgerard at gmail.com wrote:

> At this point, I'd whip out the Swiss Army Chainsaw(tm) of Perl:
> 
> nginx -V 2>&1 | perl -ne 'next unless /--conf-path=(\S+)/; print "$1\n"'
> 
> ...and I know in more recent Perls you can use 'say' instead of that print, but
> portability was mentioned, so I didn't want to assume.  :)
> 
> HTH-
> Brian

a decade ago i probably would have done the same thing; i've since ditched perl
in favor of python and rarely think about perl now. i was shooting for something
that would mostly "just work" no matter where i tried it, so i figured i'd need
to use the base tools (awk/sed/whatever). but this solution definitely
worked across all the platforms i tested it on, as perl was already installed.
i suppose perl might be just about everywhere by default - and if that turns out
to be the case, this is a great solution.

thanks!


More information about the TriLUG mailing list