The lpr command makes a copy of your file and stuffs it in the system's print queue (a process called spooling), so you can change or delete the original file without harming your printout.
The lpr command will accept two optional flags:
-r Delete the file after printing.
-s No spooling (don't make a temporary copy for printing).
The -r flag tells the system to delete the file after printing, and -s tells the system to print directly from the original file instead of spooling to the print queue. Of course, if you specify the -s flag, you can't modify or delete the original file while it's printing, but this option can save a bit of time (since no copy is made) when the original file is big.
Here are some examples using the -r and -s flags:
lpr -r humongous Delete the file humongous after printing.
lpr -s humongous Print the file humongous without spooling.< /EM>
lpr -r -s humongous Print the file humongous without spooling and t hen delete it.
Customizing Your Printouts
The lpr command is a no-frills way to print your files. It doesn't do any fancy formatting; it just dumps your file on the printer. If you'd like to format your printout (paginate, add a title, set margins, or control the page length), you can use the pr command in conjunction with lpr. By default, pr will add page numbers and a title consisting of the file's name and the date and time it was last modified. But you can do lots of other fancy formatting as well. Here are some of the options that pr supports:
-d Double-space the printout.
-h <my title> Specify a title for the page header (the default is the file name).
-Ln Set the page length to n lines (the default is 66).
-On Set the margin to n characters (the default is 8).
-T Suppress the page header.
-2 | -3 | -4 Print output in two, three, or four columns (as in a newspaper).
Typically, the output from pr is sent only to your printer (by piping the output to lpr, as shown in the following examples), but if you leave off the lpr step, you'll see the output on the screen instead. Here are some examples using the pr command to print a file named panda97.txt--for example, with no options specified, just adding page numbers and the default title (file name and date):
pr panda97.txt | lpr
Here we've specified a more meaningful title for the printout:
pr -h "Financial Report" panda97.dat | lpr
And now we've set the page length to 55 lines, set the margin to 5 spaces, and added double-spacing:
pr -h "Financial Report" -l55 -o5 -d panda97.dat | lpr
Stop the Presses!
If you send a file to the printer by mistake, you might be able to snatch it from the print queue before it's too late. First use lpq to find the job number:
lpq
Rank Owner Job Files Total Size
1st hermie 17 really-humongous 2317678 bytes
In the example shown here, the job number is 17. Once you know the job number, enlist the assistance of lprm to remove that file from the queue as follows (using job 17 as an example):
lprm 17
Previous Lesson: Spell Checking
Next Lesson: Joining Files
Comments - most recent first
|
|
||