如何在Linux上搜索整个手册页?


18

有时我需要在所有手册页中查找某些单词。我知道apropos,但是,如果我了解其手册权利,它将搜索仅限于描述。

每个手册页中都有简短说明。apropos在描述中搜索关键字的实例。

例如,如果我查找“ viminfo”之类的词,我将一无所获...

$ apropos viminfo
viminfo: nothing appropriate.

...尽管该词存在于Vim手册的第二部分(已安装在我的系统中)。

   -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".

那么,如何在每本手册的每个部分中查找一个单词呢?

Answers:


30

来自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.

这会直接为我打开联机帮助页(vim,然后是ex,然后gview是...),因此您可以添加另一个选项,例如-w了解要显示的联机帮助页。

$ 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
-wK组合特别有趣
Leo Ufimtsev

6

在中使用global apropos选项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.

因此,man -K viminfo将为您提供所需的页面。


0
$ man -K "fopen"

给你输出

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

y 打开/显示手册页

n 继续搜索

q 退出搜索


0

NetBSD具有全文搜索实现,apropos(1)该实现可以搜索手册页的全部内容,而不仅限于此NAME部分。您可能需要检查一下。

也有一个基于Web的界面:man-k.org


免责声明:我是这两种工具的开发商。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.