Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex sed-E和sed-E有什么区别_Regex_Linux_Sed_Debian - Fatal编程技术网

Regex sed-E和sed-E有什么区别

Regex sed-E和sed-E有什么区别,regex,linux,sed,debian,Regex,Linux,Sed,Debian,我正在研究一些旧代码,我发现我以前使用 sed -E 's/findText/replaceWith/g' #findText would contain a regex 但我现在试着 sed -e 's/findText/replaceWith/g' 它似乎做了同样的事情,还是真的? 我记得我做这件事是有原因的,但我记不起来了,而且做“男人sed”也没用,因为他们没有任何关于-E-only-E的东西,这没有多大意义 -e, --expression=script Append the

我正在研究一些旧代码,我发现我以前使用

sed -E 's/findText/replaceWith/g' #findText would contain a regex
但我现在试着

sed -e 's/findText/replaceWith/g'
它似乎做了同样的事情,还是真的? 我记得我做这件事是有原因的,但我记不起来了,而且做“男人sed”也没用,因为他们没有任何关于-E-only-E的东西,这没有多大意义

-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意味着它将与正则表达式匹配

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;
从中,BSD sed中的
-E
用于支持扩展正则表达式