Print Man Pages


man -t

As easy as it is to view man pages using a terminal program, sometimes it's necessary to print out a man page for easier reading and cogitation. Printing a man page isn't a one-step process, however, and the commands that round out this particular section are actually using principles that will be covered extensively later. But if you want to print out a man page, this is the way to do it. Just have faith that you'll understand what these commands mean more fully after reading upcoming chapters.

Let's say you have a printer that you have identified with the name hp_laserjet connected to your system. You want to print a man page about the ls command directly to that printer, so use the -t option (or --troff) and then pipe the output to the lpr command, identifying your printer with the -P option.

$ man -t ls | lpr -P hp_laserjet 


Note

You'll learn about the pipe symbol (|) in Chapter 4, "Building Blocks," and lpr in Chapter 6, "Printing and Managing Print Jobs."


In just a moment or two, depending upon the speed of your computer and your printer, hp_laserjet should begin spitting out the man pages for ls. Maybe you don't want to actually print the pages, however. Maybe just creating PDFs of the man page for the ls command would be enough. Once again, the commands to do so might seem a bit arcane now, but they will be far more comprehensible very soon.

Again, you use the -t option, but this time you send the output to a PostScript file named for the ls command. If that process completes successfully, you convert the PostScript file to a PDF using the ps2pdf command, and then after that finishes correctly, you delete the original PostScript file because it's no longer needed.

$ man -t ls > ls.ps && ps2pdf ls.ps && rm ls.ps 


Note

You'll learn about the > and && symbols in Chapter 4 and ps2pdf in Chapter 6.


If you want to make a printed library of man pages covering your favorite commands, or if you want that library in PDF format (which can then be printed to hard copies, if necessary), now you know how to do it. For something so simple, man is powerful and flexible, which makes it even more useful than it already is.



Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net