Looking at the man page for grep I noticed there are two different paths to the command. Does this mean I have multiple grep tools on my system? Are the synopsis lines that have the same path just different usage examples of the same tool? I am using OS X 10.10.5

     grep - search a file for a pattern

     /usr/bin/grep [-bchilnsvw] limited-regular-expression

     /usr/xpg4/bin/grep [-E | -F] [-c | -l | -q] [-bhinsvx] -e pattern_list...
          [-f pattern_file]... [file]...

     /usr/xpg4/bin/grep [-E | -F] [-c | -l | -q] [-bhinsvx]
          [-e pattern_list]... -f pattern_file... [file]...

     /usr/xpg4/bin/grep [-E | -F] [-c | -l | -q] [-bhinsvx] pattern

     The grep utility searches  text  files  for  a  pattern  and
     prints  all lines that contain that pattern.  It uses a com-
     pact non-deterministic algorithm.

A follow up question: Where do man pages come from? Are they generated dynamically or are they part of a static installation?

  • 1
    Welcome to Unix & Linux! It is preferred if you can post separate questions instead of combining your questions into one. That way, it helps the people answering your question and also others hunting for at least one of your questions. Thanks!
    – guntbert
    Commented Jun 28, 2017 at 20:18

2 Answers 2


You say you're on a macOS machine, but the manual looks suspiciously like the grep manual on a Solaris machine. Here is the manual for grep on OSX 10.9 for comparison.

On Solaris, there are several utilities with multiple implementations, and grep is one of them. The ones in /usr/bin adhere to XPG3, which is short for "X/Open Portability Guide, Issue 3". The Single Unix Specification is based on XPG4 (ref: Wikipedia X/Open article)

The XPG3 grep in /usr/bin does, for example, not support extended regular expressions, while the XPG4 grep in /usr/xpg4/bin does.

If a utility has several synopsis lines in its manual, then these are usually describing mutually exclusive ways to invoke the tool.


/usr/xpg4/bin/grep [-E | -F] [-c | -l | -q] [-bhinsvx] -e pattern_list...
      [-f pattern_file]... [file]...

 /usr/xpg4/bin/grep [-E | -F] [-c | -l | -q] [-bhinsvx]
      [-e pattern_list]... -f pattern_file... [file]...

.. show that you may use either -e or -f (or both) but that you must use one of them.

The last one,

 /usr/xpg4/bin/grep [-E | -F] [-c | -l | -q] [-bhinsvx] pattern

... shows that if you use neither -e nor -f, then the pattern needs to be specified on the command line.

See also standards(5) on Solaris.

Manuals are installed "statically", i.e. as separate files that the man command reads and displays. However, depending on your system, some of them may be groff or mandoc source files, while others may be pre-formatted as text files, sometimes stored in a sibling directory to the unformatted manuals, often called something like cat. They may sometimes also be compressed. Read the man manual on your system (man man) to see how manuals are handled there.

Most often, manuals may be found in /usr/share/man, /usr/local/share/man, or some such location.

  • You are right! I forgot I was ssh-ed to a Solaris machine when I looked at the man pages. This clears up the first part of my question, Thanks! Commented Jun 29, 2017 at 18:31
  • @SheepPlusPlus Added an answer to the second part of your question too.
    – Kusalananda
    Commented Jun 29, 2017 at 19:34

Manual pages are dynamically formatted, but the content is static. Its configuration, including the location of the actual preformatted manual pages, is typically defined in /etc/man.conf.

In relevant part on my MacOS machine:

# Every automatically generated MANPATH includes these fields
MANPATH   /usr/share/man
MANPATH   /usr/local/share/man
MANPATH   /usr/X11/man
# Uncomment if you want to include one of these by default
# MANPATH /opt/*/man
# MANPATH /usr/lib/*/man
# MANPATH /usr/share/*/man
# MANPATH /usr/kerberos/man
# Set up PATH to MANPATH mapping
# If people ask for "man foo" and have "/dir/bin/foo" in their PATH
# and the docs are found in "/dir/man", then no mapping is required.
# The below mappings are superfluous when the right hand side is
# in the mandatory manpath already, but will keep man from statting
# lots of other nearby files and directories.
MANPATH_MAP   /bin            /usr/share/man
MANPATH_MAP   /sbin           /usr/share/man
MANPATH_MAP   /usr/bin        /usr/share/man
MANPATH_MAP   /usr/sbin       /usr/share/man
MANPATH_MAP   /usr/local/bin      /usr/local/share/man
MANPATH_MAP   /usr/local/sbin     /usr/local/share/man
MANPATH_MAP   /usr/X11/bin        /usr/X11/man
MANPATH_MAP   /usr/bin/X11        /usr/X11/man
MANPATH_MAP   /usr/bin/mh     /usr/share/man

So, looking in /usr/share/man/man1, I see grep.1 which defines the content of the manual page for grep(1).

  • That has answered the follow-on question, but not addressed the main question at all.
    – JdeBP
    Commented Jun 28, 2017 at 18:01
  • Thank you for answering the follow-up question. This clears things up for me. Commented Jun 29, 2017 at 18:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .