[talk] Recursive chmod problem

ori at eigenstate.org ori at eigenstate.org
Thu Dec 2 22:39:56 EST 2021


Quoth Jonathan Drews <jondrews at fastmail.com>:
> On Thu, Dec 02, 2021 at 10:18:05PM -0500, ori at eigenstate.org wrote:
> > I'm confused. Why do you think that he's
> > wrong?
> > 
> > The shell expands the list of filenames.
> > The programs never see the globs.
> > 
> > Unless you happen to name your directory
> > 'mydir.jpg', the expansion of the glob
> > never contains a directory, so it never
> > gets passed to the program.
> > 
> > It's that simple.
> > 
> > 	myprogram *.jpg
> > 
> > is the same as typing out a list of every
> > jpg in the current directory:
> > 
> > 	myprogram a.jpg b.jpg c.jpg ...
> > 
> > there's precisely zero difference.
> > 
> 
> Thanks for the input and sorry for being so dense. This works:
> 
> chmod -R 664 */*.html
> 
> I was under the presumption that the -R flag obviated the need for
> explicit glob expansions. That is 
> $ chmod -R 660 *.pdf would be smart enough to traverse directories.
> At least that is what his book shows.

you have to give it a directory for it to recurse
into a directory; the glob NEVER makes it to the
program. The program has no idea that you ever typed
a glob.

If you have a directory called 'foo', then:

	chmod -R foo/

will descend into the directory recursively,
but you need to pass the *directory* to the
program.




More information about the talk mailing list