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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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 ...
Method 2
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.
Method 3
$ 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
Method 4
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0