17

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?

29

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
...
  • 4
    The -wK combination is particulaly interesting – Leo Ufimtsev Jul 9 '15 at 17:35
6

Use the global apropos option in 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.

So, man -K viminfo will give you the page you need.

0
$ man -K "fopen"

gives you the output

/usr/share/man/en/man3/fclose.3.gz? [ynq]  

y to open/display man page

n to continue search

q to Quit search

0

NetBSD has a full text search implementation of apropos(1) which does search across the complete content of man pages instead of restricting just to the NAME section. You might want to check it out.

There is a web based interface for it as well: man-k.org


Disclaimer: I am the developer of both of the tools.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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