Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print Text (Without File) On Linux With LPR

I've seen this done and I used to be able to do it. I had it documented in a file that was clobbered recently in a backup issue.

I have a text string I want to print from bash using lpr. I know I can print text files easily, but how can I print text that is just in quotation marks or in a string without first saving it as a file, then printing the file?

like image 864
Tango Avatar asked Nov 27 '13 18:11

Tango


People also ask

How use lpr command in Linux?

lpr submits files for printing. Files named on the command line are sent to the named printer (or the system default destination if no destination is specified). If no files are listed on the command-line, lpr reads the print file from the standard input.

Which command is used to print a file print lpr?

To print a file with a specific printer, execute the lp command with the '-d' option or lpr command with the '-P' option. Consider the following commands: lp -d <printer name> <file name>

How do I print from terminal in Linux?

To print a document on the default printer, just use the lp command followed by the name of the file you want to print.

What is use of lpr command?

The LPR command is used to print a file directly without using a Windows application that supports printing. Attention: The LPR command has a limit of 2 GB for sending print jobs.


1 Answers

You could use here-strings with bash

lpr <<< "text string"

or if your string is contained in a variable

lpr <<< "$var"
like image 179
iruvar Avatar answered Sep 19 '22 12:09

iruvar