Printing a man page

As I'll eventually get tagged to present a “Man Page of the Month” at the MonadLUG meetings, I thought I'd study a bit in advance when I found one I needed. 'top' seemed like a good candidate. But the man page is extensive, exhaustive, cross-referenced and difficult to read. So, I thought I'd print it out to scratch some notes in the margin and see if I could boil it down to a simple one-page quick reference. But how to print a man page? Well, you Google it, of course. The answer I found gave me the links I needed, even though their page neglected to display the key pipe symbols. Here's the trick:

zcat is a synonym to gunzip to pull the man page out of the .gz where it's stored. groff -man -Tps formats a file using the 'man' macro and outputs Type PostScript. Open the .ps file with the editor of your choice, and print it, convert it to PDF or whatever. So the entire command is:

zcat /usr/share/man/man1/top.1.gz| groff -man -Tps>top.ps

No comments yet.

Leave a Reply

Powered by WordPress. Designed by Woo Themes

This work by Ted Roche is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States.