开发者

find -exec option

开发者 https://www.devze.com 2023-02-23 10:08 出处:网络
Say , i want to find some files and do chmod and do something with it with another command, eg find . -name \"*.txt\" -exec chmod 666 \"{}\" && cp \"{}\" /dst \\;

Say , i want to find some files and do chmod and do something with it with another command, eg

find . -name "*.txt" -exec chmod 666 "{}" && cp "{}" /dst \;

it says

find: missing argument to `-exec'

How do I properly use this -exec construct? I think the problem is with the "&&" ? I need to use this &开发者_如何学JAVAamp;& operator in case chmod fails thank you


Just use another -exec e.g.

find . -name \*.txt -exec chmod 666 {} \; -exec cp {} /dst/ \;


Either write a little shell script and -exec that or use multiple -exec's.

0

精彩评论

暂无评论...
验证码 换一张
取 消