regex - sed problem. What am I doing wrong? -


i trying replace a[ 'xxx' ] a[ xxx ] using sed:

sed -e 's/a[ '\(.*\)' ]/a[ \1 ]/' ./test sed: -e expression #1, char xx: invalid reference \1 on `s' command's rhs 

what doing wrong?

thanks!

you need escape [ , ] this:

echo "a[ 'xxx' ]" | sed "s/a\[ '\(.*\)' \]/a[ \1 ]/" 

Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

c# - how to write client side events functions for the combobox items -

ssh client with paramiko (python) -