Linux command
help2man 命令
文本
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Generate a man page from a program's help output
help2man [program] > [program.1]
Generate with a specific man page section number
help2man -s [1] [program] > [program.1]
Add a name/description for the NAME section
help2man -n "program description" [program] > [program.1]
Include additional text from an include file
help2man --include [extra.h2m] [program] > [program.1]
Write output directly to a file
help2man -o [program.1] [program]
Suppress "info" pointer in the generated page
help2man -N [program] > [program.1]
说明
help2man generates man pages from a program's `--help` and `--version` output. It parses the structured help text and formats it as troff-style man page source, creating basic documentation automatically. The tool produces minimal man pages suitable for programs that follow GNU conventions for help output. Additional content can be added via include files (`.h2m`), which support inserting text before or after automatically generated sections using `section` headers.
参数
- -n, --name _STRING_
- Short description for the NAME section.
- -s, --section _NUM_
- Man page section number (default: 1).
- -i, --include _FILE_
- Include extra material from file. The file uses `section` headers to place text.
- -I, --opt-include _FILE_
- Like -i but does not fail if file is missing.
- -N, --no-info
- Suppress the "see also info page" pointer.
- -o, --output _FILE_
- Write output to file instead of stdout.
- -m, --manual _TEXT_
- Name of the manual (e.g., "User Commands").
- -S, --source _TEXT_
- Source of the program (e.g., "FSF", "Debian").
- -L, --locale _STRING_
- Set locale for fetching help output (default: "C").
- -l, --libtool
- Drop libtool `lt-` prefix from program name.
- -p, --info-page _TEXT_
- Name of Texinfo manual to reference.
- -h, --help-option _STRING_
- Alternative help option string to use instead of --help.
- -v, --version-option _STRING_
- Alternative version option string to use instead of --version.
- --version-string _STRING_
- Use this version string instead of running the program's version option.
- --no-discard-stderr
- Include stderr output when parsing option output.
- --version
- Show help2man version.
FAQ
What is the help2man command used for?
help2man generates man pages from a program's `--help` and `--version` output. It parses the structured help text and formats it as troff-style man page source, creating basic documentation automatically. The tool produces minimal man pages suitable for programs that follow GNU conventions for help output. Additional content can be added via include files (`.h2m`), which support inserting text before or after automatically generated sections using `section` headers.
How do I run a basic help2man example?
Run `help2man [program] > [program.1]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -n, --name _STRING_ do in help2man?
Short description for the NAME section.