Attempting to recursive chattr directories while excluding a directory, however the command which works with chown does not seem to with chattr
find /mysite/public_html ! -wholename '/mysite/public_html/images' -type d -exec chattr -R +i {} \;
find /mysite/public_html -not -path "*/images*" -type d -exec chattr -R +i {} \;
Both commands still attempt to execute the chattr command on the excluded folder. Any help appreciated.
You must prune the excluded directory. -o
continues when not pruned.
Further, find is recursive; you may not run another recursive command in it.
find /mysite/public_html -wholename '/mysite/public_html/images' -prune -o -exec chattr +i {} \;
If you prevent recursion for all directories then you can run a recursive command, and in this case you do not need to prune:
find /mysite/public_html -mindepth 1 -maxdepth 1 \! -name 'images' -exec chattr -R +i {} \;
1 Like
Thankyou, flawless execution.