sed -E 和 sed -e 有什么区别 [英] Whats the difference between sed -E and sed -e

查看:18
本文介绍了sed -E 和 sed -e 有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一些旧代码,我发现我曾经使用过

I'm working on some old code and I found that I used to use

sed -E 's/findText/replaceWith/g' #findText would contain a regex

但我现在尝试

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

它似乎在做同样的事情,或者是吗?我有点记得我这样做是有原因的,但我不记得了,做man sed"没有帮助,因为他们对 -E only -e 没有任何帮助,以太没有多大意义.

It seems to do the same thing, or does it? I kinda remember there being a reason I done it but I can't remember and doing "man sed" doesn't help as they don't have anything about -E only -e that doesn't make much sense ether.

-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.

我认为 -e 意味着它会与正则表达式匹配...

I thought -e meant it would match with a regex...

GNU sed version 4.2.1

推荐答案

从源代码来看,-E 是一个与 BSD sed 兼容的未公开选项.

From source code, -E is an undocumented option for compatibility with BSD sed.

/* Undocumented, for compatibility with BSD sed.  */
case 'E':
case 'r':
  if (extended_regexp_flags)
    usage(4);
  extended_regexp_flags = REG_EXTENDED;
  break;

来自手册-E 在 BSD sed 中用于支持扩展的正则表达式.

And from manual, -E in BSD sed is used to support extended regular expressions.

这篇关于sed -E 和 sed -e 有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆