One of our admins sent this out a couple of days ago... Might be helpful.
Hi All,
This weekend, I found myself changing the UID of all files which belonged to a particular user in ~40 directories. Since the majority of these directories contained snapshot directories, this task was impossible to complete within the time frame of the weekend without "pruning" the snapshot directory out of the find statement that I used. Since I expect that we will be seeing more and more need to perform this type of task with the merge, I thought that I would share the syntax that I used to accomplish this.
Lets assume that I am changing the UID of all files and directories, within the current directory, from 444 to 555 and that I do not want my find command to run through the .snapshot directory.
find . -name .snapshot -prune -o -user 444 -exec chown -h 555 {} ;
On Thu, 7 Jun 2001, Nail, Larry wrote:
Lets assume that I am changing the UID of all files and directories, within the current directory, from 444 to 555 and that I do not want my find command to run through the .snapshot directory.
find . -name .snapshot -prune -o -user 444 -exec chown -h 555 {} ;
That will miss files named .snapshot, and exec chown for each file. Try this instead:
find . -type d -name .snapshot -prune -o -user 444 -print | xargs chown -h 555
The above won't handle filenames with whitespace, so if you have POSIX find and xargs, try this:
find . -type d -name .snapshot -prune -o -user 444 -print0 | xargs -0 chown -h 555
On Thu, 7 Jun 2001, Nail, Larry wrote: That will miss files named .snapshot, and exec chown for each file. Try this instead:
find . -type d -name .snapshot -prune -o -user 444 -print | xargs chown -h 555
The above won't handle filenames with whitespace, so if you have
POSIX find and xargs, try this:
find . -type d -name .snapshot -prune -o -user 444 -print0 | xargs -0 chown -h 555
And if you have solaris and don't mind using undocumented syntax, you can do this...
/usr/bin/find . -type d -name .snapshot -prune -o -user 444 -exec /usr/bin/chown -h 555 {} +
The exec will *not* run every time. It will do an xargs type bundling and run once for multiple files. Handy if you haven't installed extra find and xargs programs...