How does awk
distinguish between use of BRE
versus ERE
? For sed
there is the -E
option one can use.
1 Answer
It does not need to distinguish between the two since regular expressions in awk
are always POSIX extended regular expressions.
From the POSIX specification for awk
:
The awk utility shall make use of the extended regular expression notation [...]
I'm not aware of any awk
implementation that introduces a non-standard option for switching to POSIX basic regular expressions.
The sed
utility always uses POSIX basic regular expressions unless you use it with its (so far) non-standard but fairly commonly available -E
option. The grep
utility also defaults to POSIX basic regular expressions, but the -E
option that enables it to use POSIX extended regular expressions is actually standard (while -P
for Perl-compatible regular expressions, PCRE, is non-standard and not commonly implemented on non-GNU systems). The grep
utility can additionally interpret the given expressions as plain strings with its standard -F
option.