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
用于支持扩展正则表达式