
我和男人之間有問題:
如何顯示手冊頁的各個部分?如何找出手冊頁提供了哪些部分?根據是
man man
-S
我需要取得手冊頁可用「部分」清單的參數。但是,如果我嘗試顯示git
、ls
或pwd
with 的可用部分:man -S git
。我希望有一個列表,但我得到的只是:您想要什麼手冊頁?我還有第二個問題:如何顯示手冊頁的簡短版本/預覽?解決這個問題也是我的任務。我找不到一個聽起來像我想做的事情的參數。
PS:我在 MacOS Sierra 上使用 shell
答案1
簡單的答案:
手冊頁沒有包含部分;部分包含手冊頁。
這是指您正在談論的編號部分。可以有兩個同名的手冊頁,但位於兩個不同(編號)的部分,例如,printf
.手冊printf(1)
頁涵蓋了命令列工具。手冊printf(3)
頁涵蓋了 C 函數呼叫。
您可以透過執行以下命令按順序查看兩個手冊頁:
man -a printf
當你退出第一個時,你會看到第二個。
您可以透過執行以下命令來查看它出現在哪些部分,而無需打開其中任何一個部分:
man -aw printf
除了編號部分之外其中手冊頁存在,各手冊頁也被劃分視覺上具有單獨的標題和子標題,例如「名稱」、「摘要」、「說明」等。
這些都是也稱為“節”,但“節”一詞的用法與上述編號的節明顯不同。
答案2
過去,線上手冊(「線上」與「印刷」相對)曾經有八個部分,但後來添加了更多內容。這些部分是 1, 2, ..., 8,因此您可以輸入類似的內容
man -S 4 xyz
取得第 4 節中 xyz 的手冊頁。
實際上,只有當多個部分中有相同關鍵字的手冊頁時,指定一個部分才重要。
例如:
man printf
產量
PRINTF(1) User Commands
NAME
printf - format and print data
SYNOPSIS
printf FORMAT [ARGUMENT]...
printf OPTION
DESCRIPTION
Print ARGUMENT(s) according to FORMAT, or execute according to OPTION
...
儘管
man -S 3 printf
產量
PRINTF(3) Linux Programmer's Manual
NAME
printf, fprintf, dprintf, sprintf, snprintf, vprintf, vfprintf, vdprintf, vsprintf, vsnprintf - formatted output conversion
SYNOPSIS
#include <stdio.h>
int printf(const char *format, ...);
int fprintf(FILE *stream, const char *format, ...);
int dprintf(int fd, const char *format, ...);
int sprintf(char *str, const char *format, ...);
int snprintf(char *str, size_t size, const char *format, ...);
...
嘗試man -S x intro
使用x
= 1,2,3,... 來取得各個部分的介紹。
有時你會發現類似這樣的陳述:...fork(2)
用於建立新流程;這之後通常是execl(3)
...這表示 的手冊頁fork
位於第 2 部分,而 的手冊頁execl
位於第 3 部分。
如何顯示手冊頁的簡短版本/預覽?
我不確定你的意思是什麼。man
不提供類似Get-Help
PowerShell 中的功能。whatis
給你一個非常簡短的描述,例如
whatis man
man (1) - format and display the on-line manual pages
man (1p) - display system documentation
man (7) - macros to format man pages
man [] (1) - format and display the on-line manual pages
man [] (1p) - display system documentation
man [] (7) - macros to format man pages
man [] (7) - pages - conventions for writing Linux man pages
man-pages (7) - conventions for writing Linux man pages
man.conf [] (5) - configuration data for man
man.conf [man] (5) - configuration data for man
答案3
答案4
[1.]
我希望有一個列表,但我得到的只是:您想要什麼手冊頁?
-S
不用於顯示部分列表,而是要求您傳遞部分列表您想要的部分搜尋順序。例如
xb@dnxb:/tmp$ man -S=7,6,5,4,3,2 ls
No manual entry for ls
See 'man 7 undocumented' for help when manual pages are not available.
xb@dnxb:/tmp$
上圖-S=7,6,5,4,3,2
顯示了該清單中從左到右的部分搜尋順序。如果手冊ls
包含第7節,它會顯示它。如果沒有,它將嘗試搜尋第 6 節,依此類推。如果此清單末尾不存在任何部分,則會顯示“No Manual Entry for ls”即使第 1 節存在。但這是有效的,因為清單中的第 1 部分:
xb@dnxb:/tmp$ man -S=7,6,5,4,3,2,1 ls
xb@dnxb:/tmp$
試試這兩個來證明 的搜尋順序-S
是從左到右:
xb@dnxb:/tmp$ man -S 1,1posix ls
xb@dnxb:/tmp$ man -S 1posix,1 ls
xb@dnxb:/tmp$
您也可以簡單地傳遞確切的部分,而無需-S
:
xb@dnxb:/tmp$ man 5 ls
No manual entry for ls in section 5
See 'man 7 undocumented' for help when manual pages are not available.
xb@dnxb:/tmp$ man 1posix ls
xb@dnxb:/tmp$
預設的排序可以在這裡找到(這個檔案路徑在 中描述man man
),搜尋順序從左到右:
xb@dnxb:/tmp$ \grep SECTION /etc/manpath.config
# the default is 1, n, l, 8, 3, 0, 2, 5, 4, 9, 6, 7. Multiple SECTION
SECTION 1 n l 8 3 2 3posix 3pm 3perl 5 4 9 6 7
xb@dnxb:/tmp$
如何顯示手冊頁的各個部分?如何找出手冊頁提供了哪些部分?
使用apropos [-e]
、whatis
、 或man -k
:
xb@dnxb:/tmp$ apropos statvfs #OR man -k statvfs
fstatvfs (2) - get filesystem statistics
fstatvfs (3) - get filesystem statistics
fstatvfs (3posix) - get file system information
statvfs (2) - get filesystem statistics
statvfs (3) - get filesystem statistics
statvfs (3posix) - get file system information
statvfs.h (7posix) - VFS File System information structure
sys_statvfs.h (7posix) - VFS File System information structure
xb@dnxb:/tmp$ apropos -e statvfs #OR whatis statvfs
statvfs (2) - get filesystem statistics
statvfs (3) - get filesystem statistics
statvfs (3posix) - get file system information
xb@dnxb:/tmp$
[2.]
如何顯示手冊頁的簡短版本/預覽?
我總是習慣--help
查看手冊的簡短版本(免責聲明:不完全等同),例如:
xb@dnxb:/tmp$ mplayer --help
Usage: mplayer [options] [url|path/]filename
Basic options: (complete list in the man page)
-vo <drv> select video output driver ('-vo help' for a list)
-ao <drv> select audio output driver ('-ao help' for a list)
vcd://<trackno> play (S)VCD (Super Video CD) track (raw device, no mount)
dvd://<titleno> play DVD title from device instead of plain file
-alang/-slang select DVD audio/subtitle language (by 2-char country code)
-ss <position> seek to given (seconds or hh:mm:ss) position
-nosound do not play sound
-fs fullscreen playback (or -vm, -zoom, details in the man page)
-x <x> -y <y> set display resolution (for use with -vm or -zoom)
-sub <file> specify subtitle file to use (also see -subfps, -subdelay)
-playlist <file> specify playlist file
-vid x -aid y select video (x) and audio (y) stream to play
-fps x -srate y change video (x fps) and audio (y Hz) rate
-pp <quality> enable postprocessing filter (details in the man page)
-framedrop enable frame dropping (for slow machines)
Basic keys: (complete list in the man page, also check input.conf)
<- or -> seek backward/forward 10 seconds
down or up seek backward/forward 1 minute
pgdown or pgup seek backward/forward 10 minutes
< or > step backward/forward in playlist
p or SPACE pause movie (press any key to continue)
q or ESC stop playing and quit program
+ or - adjust audio delay by +/- 0.1 second
o cycle OSD mode: none / seekbar / seekbar + timer
* or / increase or decrease PCM volume
x or z adjust subtitle delay by +/- 0.1 second
r or t adjust subtitle position up/down, also see -vf expand
* * * SEE THE MAN PAGE FOR DETAILS, FURTHER (ADVANCED) OPTIONS AND KEYS * * *
MPlayer 1.3.0 (Debian), built with gcc-5.4.0 (C) 2000-2016 MPlayer Team
xb@dnxb:/tmp$