Date: Sun, 3 Jun 2012 19:10:00 -0400 From: grarpamp <grarpamp@gmail.com> To: freebsd-questions@freebsd.org Subject: /usr/bin/find - binary operands howto Message-ID: <CAD2Ti2_d7J7DWkq%2Bu=Lwahp5xnFX7WYwZ_46zvCWAHE5CwMWrA@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAD2Ti2_d7J7DWkq%2Bu=Lwahp5xnFX7WYwZ_46zvCWAHE5CwMWrA>