Thursday, June 2, 2011

Remove executable permission on all files except directories

find . -type f -print0 | xargs -0 chmod -x

find . : search the current directory recursively
-type f : select only regular files (-type d would select directories)
-print0 : (where 0 is a zero) print the list with each file separated by a null character rather than a space. This allow handling filenames with a space in it.

xargs : execute a cmd on each argument
-0 : (where 0 is a zero) instruct xargs that argument list is null charater separated rather than by a space. Corresponds to -print0 in find.
chmod -x : remove executable permission

No comments:

Post a Comment