@StephenC's is a good answer (find -exec
) but it creates a separate sub-process for every single file. However it's perfectly functional and will only perform badly when the number of files gets really large. Using xargs
will batch up the file names into large groups before running a sub-process for that group.
@b0x0rz's is also good unless you have filenames with embedded spaces or newlines (heinous though they are).
A solution that solves both these problems is (assuming you have a decent enough find
and xargs
):
find . -type f -print0 | xargs -0 chmod 644
The -print0
causes find
to terminate the file names with a NUL character and you have to notify xargs
of that fact as well (-0
).