help2man
Create man pages from command-line help text
TLDR
Generate a man page for an executable
Specify the "name" paragraph in the man page
Specify the section for the man page (defaults to 1)
Output to a file instead of stdout
Display help
SYNOPSIS
help2man [OPTION...] [PROGRAM [ARG...]]
PARAMETERS
--help
display this help and exit
--version
output version information and exit
--error-limit=N
exit after N errors (default 3)
--no-info
omit reference to an info page
--source
output in source code format (nroff)
--version-string=STRING
use exact STRING for version
--help-string=STRING
use exact STRING for help intro
--name=STRING
use STRING as program name
--section=NUM
use NUM as man section (default 1)
--output=FILE, -o FILE
write output to FILE
--include=FILE
include extra material from FILE
--no-include
omit any extra included material
--opt-only
include options only from --help
--help-all
include all long options
--help-gnu
use GNU help2man extensions
--help-synopsis
use synopsis from --help output
--synopsis=STRING
use STRING as synopsis
--footer=STRING
use STRING as footer text
--no-discard-stderr
retain stderr from program
--program-name=STRING
use STRING to run program
DESCRIPTION
help2man is a GNU utility that automatically generates basic Unix manual pages (man pages) by parsing the --help and --version output of target programs. It extracts key elements like the synopsis, description, options list, author, and bug reporting info to create a formatted man page in troff/nroff source format.
This tool is ideal for quick documentation of command-line tools, scripts, or packages lacking dedicated man pages. It runs the program with special flags, captures stdout/stderr, and structures the content into standard sections: NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, AUTHOR, COPYRIGHT, BUGS.
Customization is possible via options to override strings, include extra files, or adjust formatting. If the program has a corresponding Texinfo manual, help2man can reference it, though primary reliance is on help text. Output can be directed to a file for installation in /usr/share/man.
While efficient, results depend on the quality of the program's help output; poor formatting yields incomplete pages requiring manual tweaks.
CAVEATS
Depends on well-formatted --help/--version in target program; output may need manual editing for accuracy or completeness. Not suitable for complex documentation.
BASIC USAGE EXAMPLE
help2man ./myscript > myscript.1
Runs myscript --help, generates myscript.1 man page.
ADVANCED EXAMPLE
help2man --name='My Tool' --section=8 --include=extra.texi ls -o ls.1
Custom name, section 8, includes extra file.
HISTORY
Created by Brendan O'Dea in 2000 for Debian; integrated into GNU in 2004. Maintained by the GNU project with contributions up to version 1.49.3 (2023), focusing on better parsing and portability.


