如果我想知道 的含义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)
在哪里
+
less
打开后执行下一个操作的符号/
命令开始搜索^\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
例如。
Mik*_*kel 11
我写了一个小脚本来做到这一点,叫做他,例如he wget -b
。
基本策略是:搜索选项(例如-b
)作为一行中的第一个单词,然后打印到下一个标题,或具有匹配缩进的下一行。
如果你不能使用它,你可以使用 basic 得到类似的东西sed
,例如
man wget | sed -ne '/^ *-b/,/^$/p'
Run Code Online (Sandbox Code Playgroud)
您可以将联机帮助页重定向到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
和空行之间的所有内容。