/usr/bin/find - binary operands howto
    grarpamp 
    grarpamp at gmail.com
       
    Sun Jun  3 23:10:02 UTC 2012
    
    
  
Given a fs with millions of inodes, multiple find runs is expensive.
As is performing the ch* on more than the minimum required inodes,
which also needlessly updates the inode ctime. So I want one find,
doing the ch* only if necessary.
I came up with this. But any true line short circuits the rest of
the -o's, which isn't desired. Using -a results similarly.
The man page says -exec returns true if util is true. ch* is usually
true unless the operation isn't permitted (file flags, read-only,
etc) or the node vanishes in a race.
The test[s] would keep -exec[s] from being always executed.
Then there is the problem of the full permutation of the initial
state of the owner and mode, say: 00, 01, 10, 11.
So how should I write this? Do I want to use -true/-false somehow?
# touch 1 ; chown 1:1 1 ; chmod 0666 1 ; ls -l 1
# find 1 \( \
\( \! \( -uid 0 -gid 0 \) -exec chown 0:0   {} \+ \) \
 -o \
\(            -perm +0222 -exec chmod ugo-w {} \+ \) \
 -o \
...
 -o \
...
\)
# ls -l 1
    
    
More information about the freebsd-questions
mailing list