Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find -exec option

Tags:

find

bash

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

like image 616
ghostdog74 Avatar asked May 29 '26 22:05

ghostdog74


1 Answers

Just use another -exec e.g.

find . -name \*.txt -exec chmod 666 {} \; -exec cp {} /dst/ \;
like image 98
Paul R Avatar answered Jun 01 '26 21:06

Paul R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!