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版本问题呢?

阅读 3.6k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进