加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式 – sed -E和sed -e之间有什么区别?

发布时间:2020-12-14 06:30:20 所属栏目:百科 来源:网络整理
导读:我正在处理一些旧的代码,我发现我曾经使用过 sed -E 's/findText/replaceWith/g' #findText would contain a regex 但我现在试试 sed -e 's/findText/replaceWith/g' 它似乎做同样的事情,还是做呢? 我记得有一个理由我做了它,但我不记得和做“男人sed”没有
我正在处理一些旧的代码,我发现我曾经使用过
sed -E 's/findText/replaceWith/g' #findText would contain a regex

但我现在试试

sed -e 's/findText/replaceWith/g'

它似乎做同样的事情,还是做呢?
我记得有一个理由我做了它,但我不记得和做“男人sed”没有帮助,因为他们没有任何东西 – 只有 – 这不太有意义的以太.

-e,--expression=script
  Append the editing commands in script to the end of 
  the editing command script. script may contain more 
  than one newline separated command.

我以为 – 这意味着它会匹配正则表达式…

GNU sed version 4.2.1
从源代码来看,-E是与BSD sed兼容的一种未记录的选项.
/* Undocumented,for compatibility with BSD sed.  */
case 'E':
case 'r':
  if (extended_regexp_flags)
    usage(4);
  extended_regexp_flags = REG_EXTENDED;
  break;

而从manual起,BSD中的-E用于支持扩展正则表达式.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读