Wednesday, November 30, 2011

Recursively chmod directories or files only

Find finds stuff and can be made to do, horrible, stuff to the things it finds.
Like this:
find . -type d -exec chmod 755 {} \;
or like this:
find . -type f -exec chmod 664 {} \;
. is the path, the current directory in this example.
-type d - find directories only.
Similarly -type f would find files only.
{} gets replaced with the current found dir/file.
\; simply marks the end of the -exec part.

Source