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

Re: changing permissions of files in directories



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]



Reply to: