bug-coreutils
[Top][All Lists]
Advanced

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

Re: chmod feature request...


From: Bob Proulx
Subject: Re: chmod feature request...
Date: Sun, 25 Jan 2004 12:35:12 -0700
User-agent: Mutt/1.3.28i

Jej wrote:
> [Sorry if I post to the wrong email, I used the debian man page email]

You have the right address.

> A nice feature to "chmod" command could be the possibility to specify a 
> --dir-only flag to apply only directories perms. eg. "chmod --dir-only 
> g+x *" would not set execute perms to files. This flag is less usefull 
> for chown and chgrp commands.

There has been discussions of this.  I am on the side that says it is
not needed.  But others are on the other side.  I don't know what the
coreutils maintainer's final opinion will be on the matter.

> Well, maybe a simple way already exists for that :)

I suggest using 'find' for doing directory traversal operations.  If
you spend just a little bit of effort learning the mechanism then it
will reward you in the capability of working with all commands
uniformly.

  find ./path -type d -print0 | xargs -r0 chmod g+x

That says for the ./path argument(s) for any that are of type
directory print them in a format terminated by a null so that any
arbitrary filename is handled.  That is piped to xargs which only runs
if there is a file to run upon, reads null terminated lines and
executes the command an efficient number of times per argument list.
Very fast and efficient.  Here are some more examples:

  find ./path -user bob -print0 | xargs -r0 ls -ld
  find ./path -name '*.html' -print0 | xargs -r0 chgrp www
  find ./path -type f -name '*~' -print0 | xargs -r0 echo rm

You mention +x and not setting execute on files.  You should know
about the +X option which is the conditional execute option.  See this
info node for the documentation.  [This was in the (fileutils) node
instead of the (coreutils) node in the older distributions.]

  info '(coreutils)Conditional Executability'

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]