Skip to main content
This question is Linux-specific
Link
Jim L.
  • 8.2k
  • 1
  • 14
  • 27
Source Link
Kristian
  • 259
  • 3
  • 13

Suppress warning: egrep is obsolescent; using grep -E

When I run egrep, it shows warning: egrep is obsolescent; using grep -E

But I'm using it as part of my shell autocomplete script that I often use, and I don't want to rewrite them.

I'm looking for way to suppress those warnings, since my autocomplete become 'ugly', e.g.: when typing mycmd myargum<TAB>, I'm expecting autocomplete to make it mycmd myargument, but instead it writes:

mycmd myargum<TAB>grep: warning: egrep is obsolescent; using grep -E
grep: warning: egrep is obsolescent; using grep -E
ent

Currently I tried doing this:

mv /usr/bin/egrep /usr/bin/egrep.backup
echo 'grep -E $@' > /usr/bin/egrep
chmod a+x /usr/bin/egrep

It works by changing the grep binary to a script that calls 'grep -E' instead.

Additional info:

$ egrep.backup --version
egrep.backup: warning: egrep.backup is obsolescent; using grep -E
grep (GNU grep) 3.8
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others; see
<https://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.

The question is:

  • Is this method okay? Will it have unintended consequences?
    • Maybe it will make egrep.backup binary still undeleted if grep package is uninstalled/purged, but this should be non issue as I never planned to do that
  • Is there any better way to suppress this warning message?