5

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?

Tango
  • 649
  • 1
  • 12
  • 29

1 Answers1

6

You could use here-strings with

lpr <<< "text string"

or if your string is contained in a variable

lpr <<< "$var"
iruvar
  • 22,736
  • 7
  • 53
  • 82
  • I think I also remember it being done with an actual option for the lpr command, as opposed to any piping or redirect. – Tango Nov 27 '13 at 18:12
  • @Tango, that is interesting. I do not see such an option with `lpr` on my installation however I am no expert on `lpr` – iruvar Nov 27 '13 at 18:14
  • 1
    I remember it took a lot of scrounging to find it, so it's not well documented, but I remember at one point finding something that was easy and surprised me. Unfortunately, I must be using different terms with Google now than I did then because I am not finding it. – Tango Nov 27 '13 at 18:26