[nycbug-talk] Follow-up on grep -P

James E Keenan jkeen at verizon.net
Wed Nov 6 21:33:46 EST 2013

Thanks to Moe Nasser's presentation tonight, I was inspired to
RTFM for grep.  In particular: grep -P.  I tried this on three different 
machines: an older Mac OSX laptop, an older Debian Linux server 
(Linode), and a more up-to-date Debian Linux server.  I maintain (so to 
speak) the first two boxes; professional sysadmins maintain the latter. 
  On the two machines I maintain, I use whatever 'grep' came with the 
machine.  And on these two machines, the '-P' option, though documented 
in the manpages, did not work, as those greps had not been compiled with 
that option.

Darwin:  grep (GNU grep) 2.5.1
$ echo "abacus babble b a ba ab cabriolet" | grep -P '(?=a)b'
grep: The -P option is not supported

Linux (mine):  $ grep -V
GNU grep 2.5.3

$ echo "abacus babble b a ba ab cabriolet" | grep -P '(?=a)b'
grep: Support for the -P option is not compiled into this 
--disable-perl-regexp binary

Linux (not mine): $ grep -V
GNU grep 2.6.3

$ echo "abacus babble b a ba ab cabriolet xenacb" | grep -P --color 
abacus babble b a ba ab cabriolet xenacb

So, your results with 'grep -P' will depend on how the version of grep 
you're using was compiled.  YMMV.

Thank you very much.
Jim Keenan

More information about the talk mailing list