"sed 's/abc/\1/'"提示"invalid reference \1",啥问题?貌似并无网传的转义错误
网上搜都说是什么什么东西忘了转义了
但我这个这么简单的,貌似没什么忘记转义的吧?
[已解决]"sed 's/abc/\1/'"提示"invalid reference \1",啥问题?
-
- 帖子: 2284
- 注册时间: 2013-05-26 6:58
- 系统: Debian 9
-
- 帖子: 2284
- 注册时间: 2013-05-26 6:58
- 系统: Debian 9
Re: "sed 's/abc/\1/'"提示"invalid reference \1",啥问题?貌似并无网传的转义错
代码: 全选
$ sed --version
sed (GNU sed) 4.2.2
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
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-sed@gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
-
- 论坛版主
- 帖子: 18279
- 注册时间: 2009-08-04 16:33
Re: "sed 's/abc/\1/'"提示"invalid reference \1",啥问题?貌似并无网传的转义错
http://stackoverflow.com/a/4609965
\(...\) would capture the characters specified inside of the parens and \1 would be used to reference the first match, this is a part of regex.
\(...\) would capture the characters specified inside of the parens and \1 would be used to reference the first match, this is a part of regex.
- vickycq
- 帖子: 4507
- 注册时间: 2011-03-20 13:12
- 系统: Debian
- 来自: 山东省寿光县
- 联系:
Re: "sed 's/abc/\1/'"提示"invalid reference \1",啥问题?貌似并无网传的转义错
代码: 全选
$ echo 'aaaXXXaaa' | sed 's/XXX/\1/'
sed: -e expression #1, char 9: invalid reference \1 on `s' command's RHS
$ echo 'aaaXXXaaa' | sed 's/XXX/\\1/'
aaa\1aaa
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
欢迎所有 Debian GNU/Linux 用户
- astolia
- 论坛版主
- 帖子: 6542
- 注册时间: 2008-09-18 13:11