3

Can I find the contents of a man page?

man bash is almost 6000 lines long, and I would like to know the section headings within the page.

  • You can download as pdf from gnu.org/s/bash/manual/bash.pdf – Pandya Oct 4 '14 at 10:12
  • This is basically what I want, thanks. Interestingly, it's not exactly the same, though a lot of text is shared. – wrgrs Oct 4 '14 at 10:19
  • @wrgrs the details will depend on your distribution. Some of them package their own versions of software and change the man pages. – terdon Oct 4 '14 at 12:58
3

If you just want the section headings, grep for them. They are in ALLCAPS and are the only lines that have no leading spaces:

$ 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

Convert it to html. You will have table of contents with links:

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

You can create a function which will do it automatically for all man pages if you like.

  • This is really neat. On Ubuntu I needed to install groff and use gunzip. – wrgrs Oct 4 '14 at 13:09
  • Yes you are right, if man pages are compressed to *.gz then gunzip -c or zcat (or even gzcat) are the right tools. – jimmij Oct 4 '14 at 13:22
  • man2html also performs this kind of conversion and can be used as a CGI script, so you can set up a local web server serving manual pages. It is available in Debian, Ubuntu and Fedora. – nwk Oct 4 '14 at 18:20
0

Assuming you haven't changed your pager, you will be viewing man pages in less.

To search in less, type /regex, e.g. /^SHELL BUILTIN COMMANDS, then press enter. Use n/N to navigate between multiple matches.

  • Actually, this is kind of the opposite of what I want! That's how to get somewhere if I know what it's called. I want to know what sections exist. – wrgrs Oct 4 '14 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.