I noticed:
chmod -R a+x
adds execute permissions to all files, not just those who are currently executable.
Is there a way to add execute permissions only to those files who already have an execute set for the user permission?
Use find
:
find . -perm /u+x -execdir chmod a+x {} \;
-execdir
; it's safer than -exec
. Also since chmod
accepts multiple files in one command line, +
instead of \;
may have better performance.
+
mode! The -execdir
instead of -exec
squashes the gained performance benefit again, though; and since find delivers full file paths anyway, does it matter much? the fastest command for me was ... -exec chmod <mode> {} +
You can use find to get all those files:
find . -type f -perm -o+rx -print0 | xargs -0 chmod a+x
Update: add -print0 to preserve space in filenames
-print0
find option and the -0
xargs option.