32

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?

Helmyano
  • 413

4 Answers4

50

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
...
muru
  • 72,889
  • 10
    The -wK combination is particulaly interesting – Leo Ufimtsev Jul 09 '15 at 17:35
  • If I do :!man -K info in gvim, will it let me edit the manual pages or will it merely display the manual pages? In VIM normal mode, I accidentally hit K when my cursor was at the word info and I was afaird that I may have messed up some of the manual pages (and hence this question) :-( – weirdo Nov 13 '20 at 01:20
8

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.

cremefraiche
  • 555
  • 3
  • 9
1

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.

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

muru
  • 72,889