有些手册页非常大。我想先查看目录,然后再转到感兴趣的部分。该怎么做?
例如:
$ man -contents ls
NAME
SYNOPSIS
DESCRIPTION
AUTHOR
REPORTING BUGS
COPYRIGHT
SEE ALSO
答案1
这有点黑客,但我想你可以用它man -w
来定位压缩的 troff 源,然后搜索章节标题(.SH
)
前任。
$ zcat "$(man -w ls)" | grep '^\.SH'
.SH NAME
.SH SYNOPSIS
.SH DESCRIPTION
.SH AUTHOR
.SH "REPORTING BUGS"
.SH COPYRIGHT
.SH "SEE ALSO"
答案2
照常运行 man,它应该运行
less
来显示内容,如这种状态行所示(在终端窗口的底部):Manual page man(1) line 1 (press h for help or q to quit)
输入
&^( )?[^ ]
(括号之间有 3 个空格),然后按回车键,您将得到以下结果:MAN(1) Manual pager utils MAN(1) NAME SYNOPSIS DESCRIPTION EXAMPLES OVERVIEW DEFAULTS OPTIONS General options Main modes of operation Finding manual pages Controlling formatted output Getting help EXIT STATUS ENVIRONMENT FILES SEE ALSO HISTORY 2.8.3 2018-04-05 MAN(1)
(奖励:用此方法你还可以获得子部分)
滚动,使感兴趣的部分或子部分位于第一行。您可能需要使用 shift-J 才能将
less
屏幕底部滚动到文件末尾之外:Controlling formatted output Getting help EXIT STATUS ENVIRONMENT FILES SEE ALSO HISTORY 2.8.3 2018-04-05 MAN(1) ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
输入
&
,然后按回车键,你将得到以下结果:Controlling formatted output -P pager, --pager=pager Specify which output pager to use. By default, man uses pager, falling back to cat if pager is not found or is not executable. This option overrides the $MANPAGER environment variable, which in turn overrides the $PAGER environment variable. It is not used in conjunction with -f or -k. The value may be a simple command name or a command with argu‐ ments, and may use shell quoting (backslashes, single quotes, or double quotes). It may not use pipes to connect multiple com‐ mands; if you need that, use a wrapper script, which may take the file to display either as an argument or on standard input. -r prompt, --prompt=prompt If a recent version of less is used as the pager, man will attempt to set its prompt and some sensible options. The default prompt looks like
请注意屏幕上的第一行保持不变。
浏览内容
根据需要重复
答案3
我发现,并非所有手册页都有正确的标签。(tmux .Sh 而不是 .SH)它的修改更加通用:zcat "$(man -w ls)" | grep '^\.[sS][hH]'