Linux Documentation – How to Search the Whole Manual Pages

documentationlinuxmansearch

Sometimes I need to look up certain words through all the manual pages. I am aware of apropos, but if I understand its manual right, it restricts search to the descriptions only.

Each manual page has a short description available within it. apropos searches the descriptions for instances of keyword.

For example, if I look up a word like 'viminfo', I get no results at all…

$ apropos viminfo
viminfo: nothing appropriate.

… although this word exists in a later section of the manual of Vim (which is installed on my system).

   -i {viminfo}
               When  using  the  viminfo file is enabled, this option sets the filename to use, instead of the default "~/.vim‐
               info".  This can also be used to skip the use of the .viminfo file, by giving the name "NONE".

So how can I look up a word through every section of every manual?

Best Answer

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.

This directly opens the manpage (vim, then ex, then gview, ...) for me, so you could add another option, like -w to get an idea of which manpage will be displayed.

$ man -wK viminfo
/usr/share/man/man1/vim.1.gz
/usr/share/man/man1/vim.1.gz
/usr/share/man/man1/gvim.1.gz
/usr/share/man/man1/gvim.1.gz
/usr/share/man/man1/run-one.1.gz
/usr/share/man/man1/gvim.1.gz
/usr/share/man/man1/gvim.1.gz
/usr/share/man/man1/run-one.1.gz
/usr/share/man/man1/run-one.1.gz
...