On BSD sed, -E
is the "extended regex" flag. On GNU sed, the documentation states that -r
is the extended regex flag, but the -E
switch works as well (though undocumented in my research).
I recall reading somewhere that -E
will be specified in the next edition of POSIX specifications, but I can't find where I read that.
(Is that true? Is there an authoritative reference for that, or a user here who is an authority?)
Just how portable is the -E
switch for sed
?
Are there standard (i.e. POSIX compliant) versions of sed
on which -E
is unsupported? (Which ones?)
Why is the -E
flag not documented for GNU sed?
Best Answer
GNU first added undocumented support for
-E
just to be compatible with BSD syntax, and the source included the commentBut in 2013 that was removed in this commit with the log message
and the commit references a defect tracker for POSIX at this page that marks as accepted adding the
-E
flag to thesed
argumentsIt doesn't seem to have made it into the latest POSIX spec (sed specific part) though, but I guess it's coming.