Printing Linux Man Pages

In my efforts to add spam and virus filtering to my mailserver project I needed to have a hardcopy of a man page. Whilst it is possible to forward the output to a file “man [command] > outputfile” or directly to the printer “man [command] | lpr” neither option is perfect. Directing the output to a file leaves extra characters in the output making the text a little unreadable in places. Directing the output directly to the printer uses a font which is over large and a waste of paper.

The trick is to use the ‘-t’ option for the man command. This reformats the the man page with groff and sends the output to stdout as normal. The reformatted page is in Postscript format (looks a little odd when viewed on screen) which can be directly sent to the printer. The result is a nicely formatted printout with page numbers.

The entire command is:
[code lang="bash"]man -t | lpr[/code]

Replace [command]with the name of the application/feature you wish to view information for.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

34SP.com Web Hosting