Re: x bit for dirs: misfeature?

Mike Castle
2001-11-20T17:19:07Z

On Tue, Nov 20, 2001 at 11:20:06AM +0000, Anton Altaparmakov wrote:
> find . -type d -exec chmod a+rx "{}" \;
> find . -type f -exec chmod a+r "{}" \;

That is a bit inefficient though. It results in one fork/exec pair for
each file and each directory.

A better solution is to use find | xargs

find /path/to/dir -type d -print0 | xargs -0 chmod a+rx
find /path/to/dir -type f -print0 | xargs -0 chmod a+r

That way, xargs bunches up the arguments into as many arguments as chmod
can handle, and calls it fewer times.

The -print0 and -0 are GNU extensions to handle spaces in names.

mrc
--
Mike Castle dalgoda@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc