5

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?

11

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.

  • Thank you. But I'm sorry for that I still don't understand why posix should remove them. – xiang Aug 2 '17 at 14:34
  • See my update; the original grep authors wanted a single grep. – Stephen Kitt Aug 2 '17 at 14:48
  • @xiang My opinion is that grep alternatives (namely fgrep and egrep) have come to the surface on different Unix variants, and that Posix tried to unify them. But I have no evidence for this. – xhienne Aug 2 '17 at 14:55
  • @xhienne they were added in V7, with the comment given in my answer, POSIX didn’t come up with the unification idea. – Stephen Kitt Aug 2 '17 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.