.bash_profile sed: \1 not defined in the RE

后端 未结 1 972
眼角桃花
眼角桃花 2020-12-24 01:52

I\'ve to set up a local web development environment on my OS X 10.9 and installed Homebrew. Next step in my guide tells me to add logic to my ~/.bash_profile wi

相关标签:
1条回答
  • 2020-12-24 02:18

    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.

    0 讨论(0)
提交回复
热议问题