When printing multiple files using lpr
and the -p
option, the name of the first file is printed in the header for all files. How can this behavior be modified such that the correct file name is printed in the header for each file?
As an example, one could print three files "file1.txt", "file2.txt", and "file3.txt" by either of the following commands:
lpr -p file1.txt file2.txt file3.txt
lpr -p file*.txt
In both cases, however, "file1.txt" is printed in the header line of each file. I would like "file2.txt" to be printed in the header for file2, and so forth (without having to print each file separately a la lpr -p file1.txt; lpr -p file2.txt; lpr -p file3.txt
).
Best Answer
The lpr man page states:
And nothing else concerning this (meaning, as it states: "Default title is the name of the file", as you didn't pass the
-h
parameter). So it looks like a misbehaviour, at least at first sight. On a second look, I notice your-p
parameter:Taking a look at the pr(1) man page:
My guess would be that this "centered header" is only calculated once, instead for each file separately. So you could try your both approaches without the
-p
parameter to check whether that introduces the problem -- or try a third approach:which would invoke
lpr
for each file separately, and thus get you rid of the described problem.