find -exec option

谁说我不能喝 提交于 2019-12-12 14:33:42

问题


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 && operator in case chmod fails thank you


回答1:


Just use another -exec e.g.

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



回答2:


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



来源:https://stackoverflow.com/questions/5604750/find-exec-option

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!