Export a manpage to (almost) any format
At some point you may want to export a manpage to a file. Using ‘man’ options, you can convert a manual page to PDF, plain text or GROFF, among other formats.
Table of Contents
In order to run the following commands, you need to have
groff installed on your system (it’s probably already installed).
Export to GROFF
GROFF is the format language used to create manual pages. To export a manpage to a GROFF file, run:
man -t <page> > manpage.groff
man -t ls > ls.groff
Export to PDF
-T<device> you can export to other file formats (‘devices’). To export to a PDF file, run:
man -Tpdf <page> > manpage.pdf
# e.g.: man -Tpdf ls > ls.pdf
Do not add a space between
-t and the device name.
Export to HTML
Using the same syntax as above, you can also export a manpage to a HTML file.
man -Thtml <page> > manpage.html
# e.g.: man -Thtml ls > ls.html
The HTML file will include an index (or ToC) at the beginning.
Export to text
Exporting a manpage to a plain text file (ASCII) is even quicker:
man -7 <page> > manpage.txt
# e.g.: man -7 ls > ls.txt
You can use
--ascii instead of
If you have any suggestion, feel free to contact me via social media or email.
Latest tutorials and articles: