Print text from terminal
CUPS understands many different types of files directly, including text, PostScript, PDF, and image files. This allows you to print from inside your applications or at the command-line, whichever is most convenient! Type either of the following commands to print a file to the default (or only) printer on the system:
lp filename
lpr filename
Use the -d
option with the lp
command to print to a specific printer:
lp -d printer filename
Or the -P
option with the lpr
command:
lpr -P printer filename
Printing the Output of a Program
Both the lp
and lpr
commands support printing from the standard input:
program | lp
program | lp -d printer
program | lpr
program | lpr -P printer
If the program does not provide any output, then nothing will be queued for printing.
More advanced options can be added to the print job with the -o
options. For exampling stapling:
lpr -P printer -o StapleLocation=UpperLeft
Source and more Details.
Last time I was using such a system, I used to prefer enscript
. It's been a while but I seem to recall it being a more sophisticated version of lpr
which could do everything that lpr
did and then some. It works like so:
enscript foo.file
It can either print directly to a printer or convert text to postscript. It should be available in the repositories of all major distributions.