Perl Regex Removed From Grep in Mountain Lion

I realized today that many of my shell scripts were no longer working since I upgraded to OS X 10.8. After digging in to it I found out that they were all bombing out on a common grep command I use for finding specific bits of text with Perl regular expressions.

grep -Po '(?<= ).*?(?= )'

I pulled up the grep man page and couldn’t find the -P switch I had always used for Perl regex. It was definitely removed.

To be completely certain, I jumped on a machine running OS X 10.7.4 to see if it was in the last OS, and sure enough there it was.

I am not sure why it was removed, but it was a great way to use powerful Perl regular expressions in a quick and convenient shell script. I really loved being able to whip up a quick shell script for something and use Patterns for the Perl regex. I know egrep has ‘extended’ regex but I like the Perl syntax. I guess it is time to leave my shell scripts behind and start writing in some more sophisticated scripting languages.

Maybe it wasn’t Apple and it was just apart of its open-source development, I don’t know, but it will be missed by me.