首页 > GNU sed 4.2.1无法匹配0x0a

GNU sed 4.2.1无法匹配0x0a

以下是我遇到的问题重放:

$ sed --version
GNU sed version 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.

GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-gnu-utils@gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
$ echo -n -e '\x0d\x0a' | sed 's/\x0a/AAAA/g'

$ echo -n -e '\x0d\x0a' | sed 's/\x0d/AAAA/g'
AAAA
$ echo -n -e '\x0d\x0a' | sed 's/\x0d\x0a/AAAA/g'

$ echo -n -e '\x0d\x0a' | perl -p -e 's/\x0d\x0a/AAAA/g'
AAAA

问题:为什么sed无法匹配\x0a?我的使用方法问题还是sed版本问题呢?


http://board.issociate.de/thread/235976/sed-and-newline-x0a.html

Because sed is a line oriented program. A reasonable implementation strategy for sed is to strip off newline characters on input, and add them back on on output.

【热门文章】
【热门文章】