使用 find -exec cp {} TARGET_DIR + 解决错误“find:缺少 -exec 的参数" [英] Solution to error 'find: missing argument to -exec' with find -exec cp {} TARGET_DIR +

查看:39
本文介绍了使用 find -exec cp {} TARGET_DIR + 解决错误“find:缺少 -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.

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

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

It worked if I used

$ 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.

And it worked if I used

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

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

The solution I found is:

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

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

Hope this helps.

解决方案

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

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

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

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

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