Re: GUN Sed Bug
Eric Blake <[email protected]>
| Newsgroups | gmane.comp.gnu.utils.bugs |
|---|---|
| Organization | Red Hat |
| Message-ID | <[email protected]> |
On 10/26/2012 03:06 PM, Eric Blake wrote: > On 10/26/2012 06:42 AM, 王森 wrote: > >> [root@localhost learn_sed]# /bin/sed "s/\'/ End/" tmp.txt >> hello world End >> I'am in china End >> [root@localhost learn_sed]# >> ### My Question >> I want to know the reason. \' be equal to Line End ? > > Thanks for the report. However, this is not a bug, but a GNU extension, > as documented here: > https://www.gnu.org/software/sed/manual/html_node/Escapes.html#Escapes > > In your particular case, end of line and end of input happen to match. > But if your sed script had also used commands like 'N', then you could > see a difference where multi-line mode makes \' match fewer places than $. By the way, POSIX says \' in sed is not portable, because implementations differ on whether it matches a literal ' or is treated like the GNU extension. If you were trying to match the literal ', then lose the backslash in your sed script. -- Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
(application/pgp-signature, 617 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQivxMAAoJEKeha0olJ0NqUfcH/jVSp9kqaJ0yRZgu35piHgI0 pVnOrr9cvaxUjqqBNoNyxB+4z6vrnPu4C4pbW3DhhyZSZW1ZNOcPviZxWBAs7QdE 7USr9QY1wRExc4bjawA4x/3kPLdpObHwLht1uDW85R/78OuH5l+7uX8bidTZadJl 4e350TxCa893ZwrxmFnAzodAYYA1RxI77tNKMJ8lBXxE1jwbzyvnqaQIgI3yjbAu QUmZFlq0kpUPNRctJK/g7NaX9E5yQ0wc8Q8vaX1FT7TGPRoP6lDHv/9LFk24YqW9 5LDuiykt44Ew2Pi0lhfQFwsmyO+WmUzz2fD7BEQRQ4kyINMSjeehsbfUgd9pWvM= =wQ7P -----END PGP SIGNATURE-----