Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #244907

Re: Printing lots of pages skips a few

From Greg Wooledge <greg@wooledge.org>
Newsgroups linux.debian.user
Subject Re: Printing lots of pages skips a few
Date 2022-02-01 13:30 +0100
Message-ID <DM0sh-Di-3@gated-at.bofh.it> (permalink)
References <DLXNL-7lF-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Printing lots of pages skips a few Pankaj Jangid <pankaj@codeisgreat.org> - 2022-02-01 10:40 +0100
  Re: Printing lots of pages skips a few Greg Wooledge <greg@wooledge.org> - 2022-02-01 13:30 +0100
    Re: Printing lots of pages skips a few Pankaj Jangid <pankaj@codeisgreat.org> - 2022-02-01 18:20 +0100
      Re: Printing lots of pages skips a few Greg Wooledge <greg@wooledge.org> - 2022-02-01 19:10 +0100
        Re: Printing lots of pages skips a few Pankaj Jangid <pankaj@codeisgreat.org> - 2022-02-02 11:50 +0100
      Re: Printing lots of pages skips a few Klaus Singvogel <deb-user-ml@singvogel.net> - 2022-02-01 21:40 +0100
        Re: Printing lots of pages skips a few Pankaj Jangid <pankaj@codeisgreat.org> - 2022-02-02 11:50 +0100
          Re: Printing lots of pages skips a few Curt <curty@free.fr> - 2022-02-02 15:00 +0100
          Re: Printing lots of pages skips a few Pankaj Jangid <pankaj@codeisgreat.org> - 2022-02-03 05:50 +0100
    Re: Printing lots of pages skips a few David Wright <deblis@lionunicorn.co.uk> - 2022-02-02 18:10 +0100
      Re: Printing lots of pages skips a few Pankaj Jangid <pankaj@codeisgreat.org> - 2022-02-03 05:50 +0100

csiph-web