3

The egrep command has been deprecated in favour of grep -E.

The POSIX definition for grep includes the following note,

This grep has been enhanced in an upwards-compatible way to provide the exact functionality of the historical egrep and fgrep commands as well. It was the clear intention of the standard developers to consolidate the three greps into a single command.

The old egrep and fgrep commands are likely to be supported for many years to come as implementation extensions, allowing historical applications to operate unmodified.

There is no POSIX command definition entry for egrep itself, however.

Does this section confirm that egrep is a recognised POSIX command (even if one that is deprecated), or does it merely note that the command used to exist and should be (as distinct from must be) supported for the foreseeable future?

Trying to put it another way, what is the situation of egrep with respect to POSIX?

Chris Davies
  • 116,213
  • 16
  • 160
  • 287

1 Answers1

7

The “Utilities Removed in the Previous Version” section in the rationale part of POSIX says that

The following utilities were removed in the previous version of this standard:

[…] egrep fgrep

This means that egrep is no longer part of POSIX (including extensions). The consequences are at least that

  • a system without egrep could be certified;
  • a strictly POSIX-compliant utility must not expect egrep to be available.

There is no expectation of any kind that a POSIX system should include egrep, just a statement that it is possible that egrep is available for historical reasons.

I don’t know whether the certification test suite includes any conformity tests for egrep when it is present. In other words, I don’t know whether a system which includes an egrep command which isn’t equivalent to grep -E would fail conformance testing. (I imagine it wouldn’t, since egrep isn’t specified by POSIX.)

Stephen Kitt
  • 434,908