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)
_Adam
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
On 2013-01-09 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
Yup, been using it for years (of course). The POSIX syntax for stuff like \a \w and \b are clumsy, ugly and hard to type. Perl does it sooooo much better. And you even can use negative look-behinds and other fun stuff! Perl's da bomb!