有没有办法只查看命令的指定选项的`man`文档

iro*_*and 28 man options

如果我想知道 的含义wget -b,我看手册man wget,然后搜索-b选项。

   -b
   --background
       Go to background immediately after startup.  If no output file is specified via the -o, output is redirected to wget-log.
Run Code Online (Sandbox Code Playgroud)

我想通过像man wget -b. (当然这行不通。)

有没有类似的方法使它成为可能?

Cos*_*tas 24

如果您less用作男人的寻呼机,您可以尝试

LESS="+/^\s+-b" man wget
Run Code Online (Sandbox Code Playgroud)

在哪里

  1. +less打开后执行下一个操作的符号
  2. / 命令开始搜索
  3. ^\s+-b-b从行首匹配的正则表达式

因此,如果您愿意,可以为 shell 安排适当的功能

function rman {
#USAGE: rman programm.name option.to.search (with "-" symbol)
LESS="+/^\s+$2" man "$1"
}
Run Code Online (Sandbox Code Playgroud)

并将其添加到~/.bashrc例如。


flu*_*ffy 14

运行man command时可以按/然后输入纯文本进行搜索。例如,键入/-b它会跳转到-b文本中的第一个实例。


Mik*_*kel 11

我写了一个小脚本来做到这一点,叫做,例如he wget -b

基本策略是:搜索选项(例如-b)作为一行中的第一个单词,然后打印到下一个标题,或具有匹配缩进的下一行。

如果你不能使用它,你可以使用 basic 得到类似的东西sed,例如

man wget | sed -ne '/^  *-b/,/^$/p'
Run Code Online (Sandbox Code Playgroud)


cha*_*aos 6

您可以将联机帮助页重定向到awk并提取该部分:

man wget | awk '/^ *-b *.*$/,/^$/{print}'
       -b
       --background
           Go to background immediately after startup.  If no output file is specified via the -o, output is redirected to wget-log.
Run Code Online (Sandbox Code Playgroud)

那部分是 a-b和空行之间的所有内容。