Print a Man Page

Reading a man page using a terminal application is easy, but I doubt if it would ever win a convenience award. Sometimes, it is necessary to print the man page. I can recommend two ways of doing this.

First, using the -t switch, when launching the man command from a terminal, causes the man page to be formatted in Postscript. Technically, it uses groff to perform the conversion. More information about this can be found within the man command’s manual page (man 1 man).

The Postscript output can be piped to lpr for printing in a CUPS printer. The following example prints the iptables manual page to the HP690C printer:

$ man -t iptables | lpr -P HP690C

Alternatively, the output can be saved to a postscript file:

$ man -t iptables > iptables.ps

More on using a CUPS printer from the CLI can be found here.

Those who have the Yelp GNOME application installed, can take advantage of its internal man page parser and HTML converter. For example, in order to display the iptables man page in Yelp, launch it like the following:

$ yelp man:iptables

From there, you can use the GNOME print dialog to print the iptables manual.

I tend to prefer the quality of the man page when it has been printed through Yelp.

Print a Man Page by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2007 - Some Rights Reserved

2 responses on “Print a Man Page

  1. Dominic Raferd Permalink →

    If you need to put the output of man into a text file, stripped of all special characters, then I have found this works. As well as using col to strip out backspaces and reverse linefeeds it also used sed to strip out ‘m’ escape codes:

    man ls|col -b|sed 's/[0-9]\{1,\}m//g'