It's Past Time To Stop Using egrep & fgrep Commands, Per GNU grep 3.8

Written by Michael Larabel in GNU on 3 September 2022 at 07:25 PM EDT. 88 Comments
GNU
GNU Grep 3.8 was released today for this commonly-used command-line utility for search plain text data. With the GNU Grep 3.8 it's now made more clear that if you are still relying on the egrep and fgrep commands, it's past due for switching to just grep with the appropriate command-line arguments.

The egrep and fgrep commands have been deprecated since 2007. Beginning with GNU Grep 3.8 today, calling these commands will now issue a warning to the user that instead they should use grep -E and grep -F, respectively. Eventually, GNU Grep will drop the egrep / fgrep commands completely but there doesn't seem to be a firm deadline yet for when that removal will happen.

Running egrep or fgrep on GNU Grep 3.8+ will show the warning of:
$cmd: warning: $cmd is obsolescent; using @grep@ @option@

The GNU Grep documentation added further details on the planned removal:
What happened to egrep and fgrep?

7th Edition Unix had commands egrep and fgrep that were the counterparts of the modern grep - and grep -F. Although breaking up grep into three programs was perhaps useful on the small computers of the 1970s, egrep and fgrep were not standardized by POSIX and are no longer needed. In the current GNU implementation, egrep and fgrep issue a warning and then act like their modern counterparts; eventually, they are planned to be removed entirely.

If you prefer the old names, you can use use your own substitutes, such as a shell script named @command{egrep} with the following contents:

#!/bin/sh
exec grep -E "$@@"

In addition to the egrep/fgrep warnings, GNU Grep 3.8 has its -P option now based on PCRE2 rather than the older PCRE, regular expressions with stray backslashes now cause warnings, and there are various bug fixes.

More details on GNU Grep 3.8 via today's release announcement.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week