Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to print a number of files from shell using lpr. I enter something like:

lpr -P PRINTERNAME ./*/dir/file.pdf

but I get "lpr: No file in print request.".

When I use ls as

ls ./*/dir/file.pdf

it correctly lists the files I want to print. Can someone help me understand what is going on?

share|improve this question
Does your command work when you specify the path to just one file? – drs Apr 23 '13 at 21:06
yes, it works when I give it a single file. I got around the issue by using a shell script: for x in `ls ./*/dir/file.pdf`; do lpr -P PRINTERNAME $x; done. Still I feel that the wildchars should have worked. – James Apr 23 '13 at 21:15
Sorry, I didn't see that you came up with this workaround before I posted my answer. Either will work... – drs Apr 23 '13 at 21:52

One of the ways I get the message

lpr: No file in print request.

is when first file by pattern is an empty file.


$ touch f0
$ echo A > f1
$ lpr f*
lpr: No file in print request.

For you for alternative - you do not need ls; actually it is prone for bad errors, e.g. if filenames contain spaces.

As an alternative you could try:

shopt -s nullglob  # So that if there are no matches you won't try to send
                   # pattern to printer.
for x in ./*/dir/file.pdf; do 
     lpr -P PRINTERNAME "$x"; 
shopt -u nullglob  # Restore

And remember to QUOTE. Always quote.

Also note:

By using lpr PATTERN all files get queued to one job named as first file in list.

That is:

# List files:
ls file*
file1 file2 file3

# Add to print job
lpr file*

Now file1 file2 and file3 should be in print queue – but not as three jobs, but one. Name of the job is given from the first file if not set by option:

Rank    Owner   Job     File(s)              Total Size
1st     user    80      file1                9248 bytes
                         +----- Actually is file1, file2, file3

If you have lp this is reported more verbosely by:

lp file*
request id is PRINTER-362 (3 file(s))

If you want you can also set a name for the job by e.g.:

lpr -T "My 3 Files" file*

Rank    Owner   Job     File(s)              Total Size
1st     user    80      My 3 Files           9248 bytes
share|improve this answer
If you use zsh instead of bash you youse setopt nullglob and unsetopt nullglob instead. – lindhe Dec 5 '15 at 18:52

Without knowing the details of the layout of your directories, I would guess that it's having trouble interpreting the different levels of subdirectories or perhaps spaces in file names.

You can try using find and piping the files to lpr with xargs:

find . -wholename "*/dir/file.pdf" -print0 | xargs -0 lpr -P PRINTERNAME
share|improve this answer

Your Answer


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.