Subject: bug#19447: chmod - problem

From: Bob Proulx <[email-masked]>
Date: Fri, 26 Dec 2014 18:24:08 -0700

tag 19447 + notabug
close 19447
thanks

Hello Tom,

Thank you for your bug report.  Trying to help and improve the tools
is always appreciated.  However it seems there is a misunderstanding.
Therefore I am marking the bug closed as housekeeping for the ticket
system.  However please lets discuss the problem in this bug ticket
until it all makes sense.  Others having the same confusion can read
it and it will help them later.

Tom wrote:
> chmod does not work recursively. The command
> 
> chmod --recursive --verbose a-x ./*.txt
> 
> only has effects in the actual working directory, but not in the
> subdirectories.

In the above you did not specify any subdirectories to chmod.  At
least I assume that all of your *.txt files are files and not
directories.  If a directory was named foo.txt and it was a directory
then of course that would be a named argument and it would be a
directory and it would recurse down it.  In order for --recursive to
make sense at least one of the arguments must be a directory.  You
can't recurse down through a file.

I could say much more but this is actually an FAQ.  Here is the FGA in
response to it.  Please let us know if this answers your questions.

  http://www.gnu.org/software/coreutils/faq/coreutils-faq.html#Why-doesn_0027t-rm-_002dr-_002a_002epattern-recurse-like-it-should_003f

Meanwhile, this is prehaps the useful command you wanted.  Try it.  It
is POSIX standard and would work on any POSIX system.

  find . -name '*.txt -exec chmod a-x {} +

If you wanted --verbose as in your question then:

  find . -name '*.txt -exec chmod --verbose a-x {} +

Again please let us know how we could improve the documentation or
whatever in order to make understanding what is happening easier.

Bob