Tuesday, 1 October 2013

sed replacement \1 not working

sed replacement \1 not working

Typing the following on the command line:
echo happy | sed -r s/\([p]\)\([p]\)/*\1*\2*/
I expect the following result:
ha*p*p*y
Instead, this is the result:
ha*1*2*y
I am using Ubuntu 12.04.3 LTS (GNU/Linux 3.2.0-53-generic x86_64) The
shell is -ksh sed is 4.2.1 December 2010
The -r option allowed me to use \( and \). I thought it would also enable
\1 and \2 but that doesn't seem to be the case. Is there another option
I'm overlooking?

No comments:

Post a Comment