If you see something like the following error message when you run a sed command:
invalid reference \1 on `s' command's RHS
then it (probably) means that your regex capture group has not been escaped properly.
So, if you are using a command like:
sed "s/foo(bar)[123]/baz\1/"
then it needs to be escaped like so:
sed "s/foo\(bar\)[123]/baz\1/"
In other words, round parentheses/brackets need to be escaped while the square brackets do not :|
Hope this helps :)
Tags:
- Log in to post comments