Why is direct invocation as either egrep or fgrep deprecated?

According to the manual page of grep-Programs,

In addition, two variant programs egrep and fgrep are available. egrep is the same as ‘grep -E’. fgrep is the same as ‘grep -F’.

Direct invocation as either egrep or fgrep is deprecated, but is provided to allow historical applications that rely on them to run unmodified.

Why are they deprecated?

Asked By: xiang


They have been removed from POSIX, with the following rationale:

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.

So egrep and fgrep are basically temporary artifacts on the way to a complete grep, which has now been available for a long time; they have served their purpose and are no longer needed, hence their deprecation.

Further evidence for this is to be found in old Unix releases: egrep and fgrep didn’t have separate manpages, they were documented in the grep manpage, which states explicitly

Ideally there should be only one grep,
but we don’t know a single algorithm that spans a wide enough
range of space-time tradeoffs.

Answered By: Stephen Kitt
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.