使用 find -exec cp {} TARGET_DIR + 解决错误 'find: missing argument to -exec' [英] Solution to error 'find: missing argument to -exec' with find -exec cp {} TARGET_DIR +

查看:37
本文介绍了使用 find -exec cp {} TARGET_DIR + 解决错误 'find: missing argument to -exec'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正准备将此作为问题发布,但在摆弄了一段时间后,我找到了解决方案.所以我想我会继续在这里发布,以防它对其他人有帮助.

I was getting ready to post this as a question, but after fiddling around with it a little longer, I found the solution. So I thought I would go ahead and post it here in case it helps someone else.

我在 find -exec cmd + 时遇到了麻烦.我收到错误:

I had trouble with find -exec cmd +. I got the error:

$ find ./ -name "*JIM*" -exec cp {} $TARGET_DIR +
find: missing argument to `-exec'

如果我使用它就有效

$ find ./ -name "*JIM*" -exec cp {} $TARGET_DIR \;

但我不想使用它,因为它为找到的每个文件派生一个新进程.

But I did't want to use that because it forks a new process for every file found.

如果我使用它就有效

$ find ./ -name "*JIM*" -exec ls {} +

它列出了我要复制的所有文件.但是 -exec cp {} $TARGET_DIR + 不起作用.

It lists all of the files that I want to copy. But -exec cp {} $TARGET_DIR + didn't work.

我找到的解决方案是:

$ find ./ -name "*JIM*" -exec cp --target-directory=$TARGET_DIR {} +

其中 --target-directory= 也可以替换为 -t

Where --target-directory= could also be replaced with -t

希望这会有所帮助.

推荐答案

正如开篇所说,我找到的解决方案是:

As mentioned in the opening post, the solution I found is:

$ find ./ -name "*JIM*" -exec cp --target-directory=$TARGET_DIR {} +

其中 --target-directory= 也可以替换为 -t

Where --target-directory= could also be replaced with -t

这篇关于使用 find -exec cp {} TARGET_DIR + 解决错误 'find: missing argument to -exec'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆