6

I would like to use a Linux distro without a desktop environment, but I need to print out homework that I type up.

I could always email it to myself and print from another computer, but it would be nice if I could just do something like print homework.txt from a bash prompt. Does anyone have a way of doing this?

16

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.

4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.