O'Reilly logo

Learning Unix for Mac OS X Tiger by Dave Taylor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Printing

Sometimes there's no substitute for hardcopy, for information that's sent to your printer and printed on a piece of paper. You know, like this book. You can generate printouts from within the Terminal itself, of course, though you're constrained to just the text that's visible in the Terminal window itself. You can also select a portion of text then use File → Save Selected Text As, and then open that file in TextEdit and print it, but that's rather a hassle.

Instead, it turns out that you can print files directly from the Unix command line in Mac OS X, and there are two ways to do this. If you want the pure Unix solution, use the lp command series, but if you have an AppleTalk network and one or more printers accessible through AppleTalk, it turns out that you can queue up AppleTalk printouts from the command line, too.

The Unix Way

The command used for sending information to the printer is lp, and there are a set of lp-related commands that you'll need to become familiar with so you can actually print something. To start, you need to ensure that you have at least one printer configured in Mac OS X. If you haven't done so yet, use the Printer Setup Utility (Applications → Utilities → Printer Setup Utility) to add one to your system. Once you have at least one printer, you can identify it by name with the lpstat command.

lpstat

With the -a flag, lpstat shows everything about the known printers:

$ lpstat -a
_192.168.1.104 accepting requests since Jan 01 00:00

In this case, you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required