Publishers of technology books, eBooks, and videos for creative people

Home > Articles

  • Print
  • + Share This
This chapter is from the book

Printing man Pages

Unix man pages are plain-text files written using a special formatting syntax (see man mdoc for a tutorial). The raw files are not suitable for printing because they contain text that the man command uses to produce boldface, underlining, and other text formatting, but in many cases you can translate the man page into HTML or PostScript.

Note that the printing techniques described here work for many, but not all, man pages, simply because some converters may not be able to handle certain formatting commands (the man pages may have been written at different times). However, you'll always be able to see the text on the screen—on the printed page you may get truncated text or missing paragraph breaks.

See Chapter 6, "Editing and Printing Files," for more on printing from the command line.

To print a man page to a PostScript printer:

  1. man -t command | lp For example, if you want a printed man page for the date command: man -t date | lp You are using the -t option of the man command to produce PostScript output and piping that into the lp command. If you're not using a PostScript printer, you will probably get a nicely formatted result because Mac OS X includes open-source Unix software that helps non-PostScript printers print PostScript. (If you are curious, see the Gimp-Print Web site,, for more about this software.)

Besides converting man pages to PostScript, you can also convert many of them to PDF or HTML (or TIFF, or JPEG, or many other formats). This will allow you to view pages in the Preview application or a Web browser and print them to any printer.

To convert a man page to PDF:

  1. man -t command > command .ps This creates a PostScript file from the man page. It is important that you include the .ps at the end of the output filename.
  2. open This opens the PostScript file. By default, the file opens in the Preview application, which automagically converts it to PDF for display.
  3. Choose File > Save in the Preview application. You get the standard Mac save-file dialog, where you choose the name and location for saving the file.
  4. Choose PDF from the Format menu in the dialog. Notice that you have the choice of several formats.
  5. Click Save. You're done.

To convert a man page to HTML:

  1. Find the raw man page. Use the -w option to the man command—for example: man -w bash bash is just the name of the command for which we want the man page. Even though bash is your shell, it is still just another command.
    groff -man -Thtml
              /usr/share/man/man1/bash.1 >
    (You might see some debugging output on your screen from the groff command, but you can ignore it. The new file, bash.html, will not contain the debugging text. The groff command is the GNU version of the roff (runoff) typesetting system and provides a variety of formatting features.
  2. You can now try viewing the HTML page with your default browser, even from the command line: open bash.html
  • + Share This
  • 🔖 Save To Your Account