Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 10 down vote accepted

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.

Source and more Details.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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