I'm trying to build a find command with multiple conditions that lead to multiple actions.  It was suggested to me that I should use only one find command for efficiency.  Here is what I have:    find $target \            \( ! -group $project -exec chgrp $project {} \;       \) , \            \( ! -user $owner -exec chown $owner {} \;            \) , \            \( ! -perm $perms -exec chmod $perms {} \;        \) , \            \( -type d -exec chmod g+s {} \; \)It seems to actually do something, however I get:find: invalid expressionand(: command not foundin the script I am trying to execute
find multiple conditions with multiple execs
bash;find
The error message indicates that ( was executed as a command, which means that one of the backslashes used for line continuation are in fact not the last character of the line. Make sure that there is no whitespace. Make sure that you're using Unix line endings (LF only, no CR).The complaint from find about an invalid expression is due to those commas. Just remove them.find $target \        \( ! -group $project -exec chgrp $project {} \;   \) \        \( ! -user $owner -exec chown $owner {} \;        \) \        \( ! -perm $perms -exec chmod $perms {} \;        \) \        \( -type d -exec chmod g+s {} \; \)You will probably save time running the commands once per batch of files instead of once per file. This is not guaranteed here because the chown, chgrp and chmod calls may proceed at different rates so directory entries may be evicted from the cache, but I'd give it a go.find $target \        \( ! -group $project -exec chgrp $project {} +   \) \        \( ! -user $owner -exec chown $owner {} +        \) \        \( ! -perm $perms -exec chmod $perms {} +        \) \        \( -type d -exec chmod g+s {} + \)chgrp, chmod and chown do nothing if the file already has the right metadata, so you could call them unconditionally. Running them needlessly does cause more calls, however. The utilities will call stat again after find has done so, but the inodes are highly likely to still be in the cache, so this may be worthwhile. You can save a call by combining chgrp into chown.find $target -exec chown $owner:$project {} + \        -exec chmod $perms {} + \        -type d -exec chmod g+s {} +