On Mon, Nov 16, 2020 at 09:15:11AM +0100, Paul de Weerd wrote:
> Hi Andreas,
> 
> On Mon, Nov 16, 2020 at 08:53:36AM +0100, Andreas Kusalananda Kähäri wrote:
> | On Thu, Nov 12, 2020 at 08:51:22PM +0100, Paul de Weerd wrote:
> | > Hi all,
> | > 
> | > I misread find(1) and did:
> | > 
> | > [weerdpom] $ find path/to/cam -name \*.JPG -exec cp {} path/to/store +
> | > find: -exec no terminating ";" or "+"
> | 
> | Not really what you're asking for, but...
> | 
> | What you seem to want to do can be done with
> | 
> |     find path/to/cam -name '*.JPG' -exec sh -c 'cp "$@" path/to/store' sh 
> {} +
> 
> Thanks, I've solved this in the past with small scripts in my homedir
> or going to `find | xargs -J`.  I'll add your suggestion to my list.
> 
> | Or, with GNU coreutils installed,
> | 
> |     find path/to/cam -name '*.JPG' -exec gcp -t path/to/store {} +
> 
> Ugh, installing GNU stuff for something like this... :)  Besides, the
> problem is more generic than just cp(1).  Do all GNU tools that (by
> default) have the target argument as the last argument support -t?  I
> mean, I know cp, mv and ln do, but do they all?
> 

That was just given as a suggestion for *if* you happened to have
coreutils installed.  Personally, I would opt for the "-exec sh -c"
variant as it's portable to any sh shell and find/cp implementation (I'm
often working on several different Unices).

The coreutils' info documentation says that the non-standard convenience
option -t (or --target-directory) is implemented for cp, install, ln,
and mv.

-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.

Reply via email to