man -f (1) 代表什麼?

man -f (1) 代表什麼?

我正在看著-f男人身上的旗幟,描述如下:

   -f, --whatis
          Equivalent to whatis.  Display a short description from the manual page, if available.  See whatis(1) for details.

當我實際使用-f條目時,末尾總是有一個括號,有時您會得到多個條目。

結果範例man -f

man -f grep

grep (1)             - print lines matching a pattern

man -f man

man (7)              - macros to format man pages
man (1)              - an interface to the on-line reference manuals

man -f git

Git (3pm)            - Perl interface to the Git version control system
git (1)              - the stupid content tracker

我猜所有正常的程序描述都以(1).

誰能解釋一下正在搜尋哪些其他清單以及如何識別括號內不同數字的含義?

man Git注意:我還注意到,對於 git,我可以通過執行而不是man git.來獲取(下午 3 點)手冊頁。這似乎違反直覺,man git將包含手冊git但不Git包含man -f git兩者的返回資訊。

答案1

括號中的內容(在某些系統上可能是字母和數字的組合,但大多數情況下只是一個數字)指的是手冊中的部分。 「手冊」是可用手冊的總卷。

在我的 OpenBSD 系統上,手冊中引用了這些部分man(1)(也稱為“命令手冊man”,您可以使用 閱讀man man):

1         General commands (tools and utilities).
2         System calls and error numbers.
3         Library functions.
3p        perl(1) programmer's reference guide.
4         Device drivers.
5         File formats.
6         Games.
7         Miscellaneous information.
8         System maintenance and operation commands.
9         Kernel internals.

各系統的部分編號大多相同,但可能有細微偏差。這些部分沒有標準化,至少不是 POSIX 標準化的,所以我認為它們大多是傳統的。

有時,您必須知道您要查找哪個部分。printf例如,手冊 就是這種情況。printf(1)指的是printfshell 的實用程序,而printf(3)描述的是 C 函式庫例程printf()。如果您輸入man printf,您可能會得到printf(1)。若要取得 C 庫函數的手冊,請使用man 3 printf.

這些部分似乎是在 1971 年貝爾實驗室推出的第三版 UNIX(第一個用 C 而不是彙編語言編寫的 UNIX)中引入的。

第三版 UNIX 手冊包含以下部分

I.    Commands
II.   System calls
III.  Subroutines
IV.   Special files
V.    File formats
VI.   User-maintained programs
VII.  Miscellaneous
VIII. Maintenance

答案2

摘自man man(5段):

   1   Executable programs or shell commands
   2   System calls (functions provided by the kernel)
   3   Library calls (functions within program libraries)
   4   Special files (usually found in /dev)
   5   File formats and conventions eg /etc/passwd
   6   Games
   7   Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
   8   System administration commands (usually only for root)
   9   Kernel routines [Non standard]

答案3

這些數字表示資訊來自手冊的哪個部分(最初是指您書架上的手冊集中的哪個實體卷)。

man man

   The table below shows the section numbers of the manual followed by the  types  of
   pages they contain.

   1   Executable programs or shell commands
   2   System calls (functions provided by the kernel)
   3   Library calls (functions within program libraries)
   4   Special files (usually found in /dev)
   5   File formats and conventions eg /etc/passwd
   6   Games
   7   Miscellaneous   (including  macro  packages  and  conventions),  e.g.  man(7),
       groff(7)
   8   System administration commands (usually only for root)
   9   Kernel routines [Non standard]

後來又增加了一些額外的“部分”。例如,(3pm)上面引用的文本中的 指的是 perl 模組(或庫)。

答案4

指令後面的數字告訴您指令的文件位於手冊頁的哪個部分...例如,grep(1) 表示 grep 的手冊頁可以在手冊頁的第 1 部分中找到。

不同風格的 UNIX 和不同發行版的 Linux 對於哪些指令的文件位於哪個部分有不同的約定。

相關內容