1) echo 'axaaxaaaxa{1,2}' | sed 's{a\{1,2\}{b{g'

a) axaaxaaaxb
GNU
b) ERROR
Darwin, FreeBSD, NetBSD, OpenBSD, IRIX
c) bxbxbbxb{1,2}
AIX, HP-UX, Solaris, Tru64

2) echo abca.c | sed 's.a\.c.xyz.g'
a) xyzxyz
Darwin, FreeBSD, GNU, IRIX, NetBSD, OpenBSD
b) abcxyz
Solaris, AIX, HP-UX, Tru64

So BSD, IRIX, GNU behave the same in that they strip the slash before passing it to the regex matcher. (GNU is more lenient in that it does not check for balanced parentheses). AIX, HP-UX, Solaris, Tru64 are in the other camp (compatible with GNU sed up to 4.0.x).

3) echo 'abc' | sed 's1a\(b\)c1A\1C1g'
a) A1C
GNU
b) AbC
AIX, Darwin, FreeBSD, HP-UX, IRIX, NetBSD, OpenBSD, Solaris, Tru64

Hmm, so on the RHS on the other hand the string is passed as-is. It is interesting that for digits, GNU sed is the only one to follow Paul's interpretation ("\x produces literal character x") of SUSv3. :-)

Paolo


Reply via email to