[wellylug] permissions munted

Alastair Porter alastair at porter.net.nz
Fri Jul 31 14:01:03 NZST 2009


On Fri, 2009-07-31 at 13:56 +1200, Andrew Ruthven wrote:
> On Fri, 2009-07-31 at 12:58 +1200, David Antliff wrote:
> > On Fri, Jul 31, 2009 at 08:47, Cliff Pratt<enkidu at cliffp.com> wrote:
> > > find /path/to/base -type d -exec chmod 755 '{}' \;
> > 
> > Much to my surprise, I discovered a few weeks ago that -exec is
> > deprecated. Apparently one should use -execdir instead (see manpage
> > for details).
> > 
> > I can't remember exactly what I was doing at the time, but I found
> > this out when -exec started behaving in a non-familiar way. I do
> > recall I was quite puzzled.
> 
> Another approach is to use xargs.
> 
> find /path/to/base -type d | xargs chmod 755
> find /path/to/base -type f | xargs chmod 644

Be careful about using find/xargs with files with spaces in them.
Better to use:
find /path/to/base -type d -print0 | xargs -0 chmod 755
find /path/to/base -type f -print0 | xargs -0 chmod 644

Make sure -print0 is always the last parameter on the find command.

Alastair



More information about the wellylug mailing list