Linux

如何在 Linux 上搜尋整個手冊頁?

  • April 19, 2016

有時我需要通過所有手冊頁查找某些單詞。我知道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".

那麼如何在每本手冊的每個部分查找一個單詞呢?

來自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, then ex, then 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
...

引用自:https://unix.stackexchange.com/questions/195571