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.
man -t | lpr
Replace [command] with the name of the application/feature you wish to view information for.