Re: changing permissions of files in directories
On Wed, 8 Oct 2003, 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.
>
<snip>
Although it may use more processes, I use this format for many situations:
<some command to stdout> | while read line; do
statements
done
so,
find PATH -type f | while read line; do
chmod 0644 $line;
done
Cheers,
-K
Reply to: