[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Printing lots of pages skips a few



On Tue 01 Feb 2022 at 07:29:09 (-0500), Greg Wooledge wrote:
> On Tue, Feb 01, 2022 at 03:04:06PM +0530, Pankaj Jangid wrote:
> > I tried to print ~40 pages using the following combination of commands:
> > 
> > find . -name "pref***.pdf" | xargs lp
> > 
> > The result was that a couple of pages were missed.
> 
> That command is fundamentally broken.  It will fail if any of the
> matching filenames contain whitespace, single quotes or double quotes.
> 
> A correct version would be:
> 
> find . -name "pref*.pdf" -exec lp {} +
> 
> That's the preferred one.  If you're really old-fashioned and just cannot
> live without xargs, the first thing you must realize is that POSIX xargs
> is fundamentally incapable of doing this correctly.  GNU xargs has a -0
> extension, though, which makes it possible:
> 
> find . -name "pref*.pdf" -print0 | xargs -0 lp
> 
> That one is acceptable, albeit longer, less efficient and less portable.

(… goes off to check .bashrc, and comes back …)

I find frequent use of xargs, and they're almost all on account of

needing  …  -print0 | LC_ALL=C sort -z | xargs -0 …  (± the locale).

And in the OP's case, this might save a little effort, because my
next step in the investigation would be to check the files in
/var/spool/cups/c* to make sure that all the files had actually
been queued. If so, what does each file report as happening.
(The files are timestamped, so their later repeat printings can
be discounted.)

The OP might want to sort on date and/or sequence number if they
were going to bother to sort at all. The sort options are
complicated a little by the choice of ddmmyy, rather than yymmdd,
for the date field.

Cheers,
David.


Reply to: