[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: changing permissions of files in directories



On Wed, 2003-10-08 at 04:46, Colin Watson wrote:
> On Wed, Oct 08, 2003 at 10:04:01AM +0000, Adam wrote:
> > On Wednesday 08 October 2003 08:00, Lukas Ruf wrote:
> > > find <path> -type f | xargs chmod 0644
> > 
> > I would have come up with
> > 
> > find PATH -type f -exec chmod 0644 '{}' ';'
> > 
> > Is the version with xargs better, and how?
> 
> The version with xargs is much better: it runs a single instance of
> chmod with all the files (or as many as will fit) as arguments, rather
> than running a separate instance of chmod for every file.
> 
> The downside is that you can only use xargs this way for programs that
> let you specify an arbitrary number of filenames lasting up to the end
> of the command line. Fortunately, most command-line Unix utilities
> behave this way or can be made to behave this way.
> 
> Cheers,
> 
> -- 
> Colin Watson                                  [cjwatson@flatline.org.uk]

My file archive contains files for 3 different platforms.  Some of the
filenames contain spaces, causing xargs to break them up, so I read the
man pages for find and xargs and ended up with something similar to
this:

find <path> -type f -print0 | xargs --null chmod 0644

This seems to work, but I'm no expert.  Are there any problems with this
approach?

-- 
David Jolly
dibbler@frii.com




Reply to: