On 11/16/20 12:15 AM, 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?

| I quite like Alexander's proposed smaller diff.

Making it more clear to the user that + must follow {} is the thing
I'd like to achieve, so yeah :)  No strong feelings over his vs my
diff.

Cheers,

Paul


Hi Paul,

I've stumbled on this issue a number of times myself. The easiest workaround I've found is to do something like this:

find /tmp/1 -type f -name "*" -print0 | xargs -0 -I{} cp {} /tmp/2/

No GNU stuff needed.

Regards,

Jordan

Reply via email to