[RndTbl] Grep supports Perl regexp! Who knew?
Gilbert E. Detillieux
gedetil at cs.umanitoba.ca
Wed Jan 9 12:18:51 CST 2013
On 2013-01-09 12:01, Adam Thompson wrote:
> Command Line Magic (@climagic) tweeted at 11:58 AM on Wed, Jan 09, 2013:
> grep -o -P "(?<=CRON\[)\d+" /var/log/syslog # GNU grep supports perl regex expressions. This gives only the PID on CRON lines in syslog.
> (https://twitter.com/climagic/status/289068621362241537)
Who knew? I did, and so did the man page...
-P, --perl-regexp
Interpret PATTERN as a Perl regular expression. This is highly
experimental and grep -P may warn of unimplemented features.
And whether or not it's "highly experimental" (i.e. likely to blow up,
or just likely to no be supported in future versions?), it is highly
non-portable, since it's only GNU grep that supports it.
Actually, I had discovered this extension when researching the grep
family for an RTFM topic a few years ago...
http://www.muug.mb.ca/meetings/09-10.html#apr
--
Gilbert E. Detillieux E-mail: <gedetil at muug.mb.ca>
Manitoba UNIX User Group Web: http://www.muug.mb.ca/
PO Box 130 St-Boniface Phone: (204)474-8161
Winnipeg MB CANADA R2H 3B4 Fax: (204)474-7609
More information about the Roundtable
mailing list