I want to learn how to search for a file by giving the content within it as a parameter. I can then apply the solution to search for commands contributed by Richard Stallman (through man pages).

  • 1
    The answer below is perfect for what you're asking in the title, but mind that searching compressed man pages like is not the same as searching text / binary files (for those you'll want to use the regular grep).
    – kos
    Commented Jan 31, 2016 at 11:14
  • @kos good point. I tried to edit the question to add "man", but it falls below the limit, so I let it go ;)
    – philsf
    Commented Jan 31, 2016 at 11:22
  • @philsf Judging from the inconsistency in the question apparently they assumed that either way it would be the same; you could still add "remove the z for non-gzip-compressed files" to your answer though ;)
    – kos
    Commented Jan 31, 2016 at 11:31
  • 1
    Just manpages or files in general?
    – muru
    Commented Feb 1, 2016 at 1:43
  • actually both... i wanted to know all the commands contributed by Stallman i can obviously use the solution for general files as well Commented Feb 1, 2016 at 12:22

3 Answers 3


From man man:

-K, --global-apropos
      Search for text in all manual  pages.   This  is  a  brute-force
      search,  and is likely to take some time; if you can, you should
      specify a section to reduce the number of pages that need to  be
      searched.   Search terms may be simple strings (the default), or
      regular expressions if the --regex option is used.

-w, --where, --location
      Don't actually display  the  manual  pages,  but  do  print  the
      location(s) of the source nroff files that would be formatted.


man -wK 'Richard M Stllman'

Though manpages typically have just Richard Stallman, with a variable amount of space between the two words, so a regex might be appropriate:

      Show all pages with any part of  either  their  names  or  their
      descriptions   matching   each   page   argument  as  a  regular
      expression, as with  apropos(1).   Since  there  is  usually  no
      reasonable  way  to  pick  a  "best"  page  when searching for a
      regular expression, this option implies -a.


man --regex -wK 'Richard *Stallman' 
  • This solution uses only the intended tool (man) so it is much more elegant than mine. This answer should be the accepted one.
    – philsf
    Commented Sep 16, 2018 at 15:02

This command will show you the filenames of man files that contain the keyword Stallman:

zgrep -l Stallman /usr/share/man/man?/*

Output in my 15.10 begins with:


Then, you can browse as usual, with man cat, man comm, etc.


This method does not search the entire manpages for a keyword, but only each manpage's title and short description. It will not be enough in your case, but useful to quickly look up something. If it does not return the desired results, you have to use @philsf's answer.

You can use the apropos command to quickly search all installed manpages' title and description for a keyword:

$ apropos chat
chat (8)             - Automated conversational script with a modem
chattr (1)           - change file attributes on a Linux file system
empathy (1)          - GNOME multi-protocol chat and call client

You can display a known manpage's description using whatis:

$ whatis empathy
empathy (1)          - GNOME multi-protocol chat and call client

As I said, this method will not search the entire manpage body, therefore apropos Stallman returns nothing...

You must log in to answer this question.

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