Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Since egrep is essentially grep -E I would expect it to be an alias that calls grep with that option. However on my system

file `which egrep`

shows it is an executable. Also egrep as an alias only invokes egrep with the color option. Why is it not an alias? Do they compile a separate binary for egrep?

Just curious...

share|improve this question

It depends on the OS and the version of the grep tools installed.

Some examples for systems I happen to have access to:

  • Ubuntu 11.04, GNU grep 2.6.3: /bin/grep, /bin/fgrep, and /bin/egrep are three distinct executable files with different sizes.

  • GNU grep 2.10 (just released a few days ago), built from source: the same.

  • Cygwin: the same.

  • CentOS 5.6 (a clone of Red Hat), GNU grep 2.5.1: /bin/egrep and /bin/fgrep are symlinks to /bin/grep.

  • GNU grep 2.5.1 built from source: egrep and fgrep are small shell scripts that invoke grep.

  • Solaris 9: three different files (Solaris tools, not GNU).

share|improve this answer

They used to be separate executables, but these days it's usually a single executable with three hard links ("grep", "fgrep" & "egrep") all pointing to the same program: the program checks which name it was started as, and behaves accordingly.

So what you're running is an enhanced egrep with the features of the other two programs included: and calling it by different names, or with -E gives you the features you expect.

If you type

ls -i `which grep`

and the same for fgrep and egrep you may see that they all have the same inode number, which means they are all the same file.

share|improve this answer
Well at least on my system they have different inode number (off by 3). but in principle I understand your point. they could be hard symlinks and the grep program could look up argv[0] to find out what options to apply. – Rohit Banga Nov 19 '11 at 14:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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