Previous Section  < Day Day Up >  Next Section

Recipe 1.8. Printing man Pages

1.8.1 Problem

You want to print a man page, nicely formatted and readable. You have tried man foo | lpr, but it doesn't look very good. The margins are too small, and all the formatting is lost.

1.8.2 Solution

One way to print a nicely formatted man page is to use the -t flag, which formats it especially for printing. man finger is good for practice, because it's only two pages long:

$ man -t finger | lpr

To use a networked printer:

$ man -t finger | lpr -P printername

To see your available printers:

$ lpstat -p -d

Another option is to use the following command, which formats the page in HTML and sends it to the web browser of your choice:

$ man -Hmozilla finger

Then use the browser's print command. Be sure there is no space between -H and the browser name.

1.8.3 Discussion

All of the major Linux distributions ship with CUPS, the Common Unix Printing System. CUPS supports both the System V (lp) and Berkeley (lpr) commands. This recipe uses the Berkeley commands. Here is the System V equivalent.

$ man -t finger | lp

To use a networked printer:

$ man -t finger | lp -d printername

1.8.4 See Also

  • man(1), lpr(1), lp(1)

  • Chapter 14

  • CUPS Software Users Manual (http://localhost:631/documentation.html)

    Previous Section  < Day Day Up >  Next Section