查找手册页的内容

查找手册页的内容

我可以找到手册页的内容吗?

man bash将近 6000 行长,我想知道页面中的章节标题。

答案1

如果您只想要章节标题,grep则可以。它们全部大写,并且是唯一没有前导空格的行:

$ man bash | grep '^[A-Z]'
BASH(1)                                General Commands         Manual                                BASH(1)
NAME
SYNOPSIS
COPYRIGHT
DESCRIPTION
OPTIONS
ARGUMENTS
INVOCATION
DEFINITIONS
RESERVED WORDS
SHELL GRAMMAR
COMMENTS
QUOTING
PARAMETERS
EXPANSION
REDIRECTION
ALIASES
FUNCTIONS
ARITHMETIC EVALUATION
CONDITIONAL EXPRESSIONS
SIMPLE COMMAND EXPANSION
COMMAND EXECUTION
COMMAND EXECUTION ENVIRONMENT
ENVIRONMENT
EXIT STATUS
SIGNALS
JOB CONTROL
PROMPTING
READLINE
HISTORY
HISTORY EXPANSION
SHELL BUILTIN COMMANDS
RESTRICTED SHELL
SEE ALSO
FILES
AUTHORS
BUG REPORTS
BUGS
GNU Bash 4.3                               2014 February 2                                    BASH(1)

答案2

将其转换为 html。您将获得带有链接的目录:

bunzip2 -c $(man -w bash) | groff -mandoc -Thtml > /tmp/bash.html && \
firefox -remote "openURL(file:///tmp/bash.html, new-tab)"

如果您愿意,您可以创建一个函数,该函数将自动为所有手册页执行此操作。

答案3

如果您习惯使用 Neovim 作为手册页,它可以做到这一点。它有一个可以使用 激活的交互式目录gO,以及一些其他有用的导航快捷方式。通过将以下变量添加到 shell 中,可以将其设置为默认手册页程序:

export MANPAGER='nvim +Man!'

:help :Man

MAN                 *ft-man-plugin* *:Man* *man.vim*

View manpages in Nvim. Supports highlighting, completion, locales, and
navigation. Also see |find-manpage|.

...

Local mappings:
K or CTRL-]               Jump to the manpage for the <cWORD> under the
                          cursor. Takes a count for the section.
CTRL-T                    Jump back to the location that the manpage was
                          opened from.
gO                        Show the manpage outline. |gO|
q                         :quit if invoked as $MANPAGER, otherwise :close.

...

To use Nvim as a manpager:
     export MANPAGER='nvim +Man!'

答案4

假设您没有更改寻呼机,您将查看less.

要在 中搜索less,请键入/regex,例如/^SHELL BUILTIN COMMANDS,然后按 Enter 键。使用n/N在多个匹配之间导航。

相关内容