Mysterious GNU sed option “-E”
A few days ago I needed to conduct a mass search and replace operation on a large text file, and figured that
sed would be a good fit. I must admit that
sed is not on the list of tools I use daily, so I just looked up a solution to a similar problem on the Net. It worked, but the command line contained an option I’ve never seen before – capital “
sed -E . . .
-E, the command failed, so I decided to find out what that option means. However, it seemed to be undocumented: neither
sed --help nor
man sed or
info sed mentioned it.
Fast forward a few minutes, and I have the answer: it is simply equivalent to “
. . . /* Undocumented, for compatibility with BSD sed. */ case 'E': case 'r': if (extended_regexp_flags) usage(4); extended_regexp_flags = REG_EXTENDED; break; . . .
Sigh. Every now and then I wish Unix was never forked or cloned.
I also wondered if there is reciprocity on the BSD side, but I only have access to an old box running FreeBSD 4.11 – the version of
sed included with it does not recognize the “