Here's the problem:
If I simply 'chmod -R' a directory tree, every single file and directory
in that tree will have its ctime changed. If you're keeping incremental
backups (which you should be!), you won't like that. It will make the
entire directory tree seem "new" at the time of your next backup. Even
files that already had modes that agree with the mode you were setting
will have their ctimes updated anyway. To test this, do 'ls -cl' on a
file, then chmod it with the mode it already has, then 'ls -cl' it
again. The mode and the ctime are changed even when it's not necessary.
Your next incremental backup will save a redundant copy of this file.
If you did that as part of a 'chmod -R' on a whole tree, you will now
eat several megabytes of tape for nothing.
The _partial_ solution:
GNU find includes options for matching modes, either exactly, or all
those specified, or any of those specified. It can also execute
arbitrary commands with the '-exec' option if it finds a hit, which
makes it possible to do a sort of "conditional recursive chmod" as it
were using GNU find. So why is this only a partial solution?
Because I don't see any way to match bits that are NOT set.
The only way I can do that is if I want to match a whole mode exactly.
For example, I could say:
find ~/dir -type f -perm 0600 -exec chmod g+r {} \;
But that would depend on finding the EXACT mode 0600. How do you do
this type of conditional chmod looking for individual cleared bits? In
other words, I want to do something like 'find -perm +mode', which looks
for *any* of the specified bits set...but in REVERSE. I want to look
for individual arbitrary bits that are NOT set, and do '-exec chmod'.
Any special incantations anyone might know to accomplish this?
BTW: I don't care that it necessarily has to be a find command. Perl,
awk, bash...whatever. It's all very kosher. <g>
--
+ Brent A. Busby, "The killer application for Windows was Visual
+ CATMIND RECORDINGS Basic. It allowed you to make your hokey, self-
+ Pekin, IL (USA) your enterprise...." --Linus Torvalds