It looks like the new version of OS X no longer supports grep -P
and as such has made some of my scripts stop working, for example:
var1=`grep -o -P '(?<=<st:italic>).*(?=</italic>)' file.txt`
I need to capture grep's result to a variable and I need to use zero-width assertions, as well as \K
:
var2=`grep -P -o '(property:)\K.*\d+(?=end)' file.txt`
Any alternatives would be greatly appreciated.
-P
? Mine has it. – Surplicegrep
actually changed fromgrep (GNU grep) 2.5.1
in 10.7 togrep (BSD grep) 2.5.1-FreeBSD
in 10.8. I guess it was because of GPL. The FreeBSDgrep
is also based on GNUgrep
and both versions ofgrep
are from 2002.--label
and-u
/--unix-byte-offets
were also removed in 10.8.-z
/--decompress
,-J
/--bz2decompress
,--exclude-dir
,--include-dir
,-S
,-O
, and-p
were added in 10.8.-Z
changed from--null
to--decompress
. – DownswingBSD grep
is way slower thanGNU grep
, can you confirm if this is still the case on 10.8 (compared toGNU grep
installed via homebrew, for example)? I'm just curious. – Gensmergrep
that comes with OS X is from 2002, and wiki.freebsd.org/BSDgrep still says that "the only TODO item is improving performance", so yeah.time grep aa /usr/share/dict/words>/dev/null
takes about 0.09 seconds with OS X's grep and about 0.01 seconds with a new GNU grep on repeated runs on my iMac. – Downswing