I am using this sed command on Linux, to patch one file, and it works fine:
sed -i -r "s/(\tpublic function __call.*)/\1\n\t\treturn null;/" rb.php
But when I try this command on OS X, I am getting an error:
sed: 1: "s/(\tpublic function __ ...": \1 not defined in the RE
So, can anybody help me to make command that will work both on Linux and OS X?
By the way, I tried command like:
sed -i '' -r "s/(\tpublic function __call.*)/\1\n\t\treturn null;/" rb.php
but it doesn't work on Linux.
(
is standard for perl, not for sed. You should use\(
instead. Mac OS X does not use GNU sed.I think adding
-E
will make it work for both.For the Mac OS X sed, use
-E
instead of-r
to get EREs. Additionally, the GNU extensions aren't there, so you'll need literal characters instead of the\t
and\n
metacharacters.Or just install GNU sed, of course.