.bash_profile sed: \\1 not defined in the RE

戏子无情 提交于 2019-11-29 22:09:58

You should use \(.*\) instead of (.*).

sed uses Basic Regular Expressions (BRE) by default, which uses \( and \) for group capturing, not just ( and ) as used in Extended Regular Expressions (ERE). Since your expression used (.*) instead of \(.*\), it is not recognised as a group capture, and thus nothing is captured for use with \1.

Some sed implementations, such as the ones provided by GNU and BSD, do have an extension for specifying the use of ERE, but it is not specified by POSIX, and you cannot use it if you want to be portable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!