DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
About files and directories

Printing a file

When you issue a print command, a copy of the file to be printed is spooled. It then waits in the print queue, along with other print jobs, until its turn comes to be printed. Because the system spools print jobs, you can go straight on to another task.

To print a file use the lp(1) (line printer) command. For example:

   $ lp myfile
   request id is laserwriter-635 (1 file)
This command sends myfile to the print queue. The ``request id'' line means that the file will be printed on the printer named ``laserwriter'', and is request number 635.

To print several files, add them to the command line, as follows:

   $ lp file1 file2 file3
This command line prints file1, followed by file2, followed by file3.

Note that it is a bad idea to print executable programs, or other files containing binary data; in general you should only print files containing text, or containing some form of data intended for printing (such as PostScript® files).

By default, files are printed in portrait orientation on the paper: to print a file in landscape orientation (that is, sideways, so that long lines fit on the page), use the following command:

   $ lp -ol file1
To print a PostScript file on a PostScript printer, you should specify that the file contains PostScript, by using the following command:
   $ lp -og
See lp(1) for more information about how to send files to the printer.

If you need to add page numbers to a long file, use the pr(1) command, which prints files to its standard output, separated into pages with a header containing the page number and date and time of printing. You can then pipe the paginated output to lp.

For example, to print /etc/profile in this way, use the following command line:

   $ pr /etc/profile | lp

Printing several copies of a file

To print several copies of a file, use the lp -n option, as follows:

   $ lp -n 3 file1
The argument to -n is the number of copies you want, in this case, three. The default number is 1.

Selecting a printer

If you know that several printers are connected to your system, and you want to send a file to a printer that is not busy, you need to know the destination printer's name. You can get a list of the printers available to you by using the lpstat(1) (line printer status) command, as follows:

   $ lpstat -s
To select one of the available printers, use the lp -d option, as follows:
   $ lp -dlaserwriter2 file1 file2 file3
This command line sends the specified files to the named printer.

You can assign a default printer for lp to use, by setting the LPDEST environment variable. Environment variables are explained in depth in ``Setting shell variables''. Add a line setting the value of LPDEST to the name of your default printer to the appropriate login script.

For example, if you are using the Korn shell and the printer you want to use by default is called postscript-2, you can add the following line to your .profile file:

   LPDEST=postscript-2; export LPDEST
postscript-2 will then become your default printer next time you log in.

Displaying a list of current print jobs

To display the list of current print jobs, use the following command line:

   $ lpstat -o
lpstat reports on printer status.

Canceling a print request

To cancel a print request, use the cancel(1) command. You need to know the print request number that was assigned when the request was first spooled. This can be found using lpstat -o. For example:

   $ cancel laserwriter-635
You can only cancel your own print requests.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 22 April 2004