-depth option for find(1)
tsclark at ihnp4.UUCP
tsclark at ihnp4.UUCP
Wed Aug 17 01:50:28 AEST 1983
Ok...here's what "find -depth" REALLY does, and why it is a good thing:
Normally, if you use find on a directory tree, it prints the name of the
directory followed by the contents of that directory (recursively). That
is, it prints as it goes down the tree. For example:
top
top/second
top/second/third
top/second/file
top/file
etc.
This is good if you are copying files since you would like the directory
created before you try to put anything in it.
What the -depth option does is list the contents of the directory first,
and then later give the name of the directory, such as:
top/second/third
top/second/file
top/second
top/file
top
This is good if you don't want to change the directory until you've changed
everything inside it. For instance:
find . -depth -exec rm {} \; (same as rm -r .)
find . -depth -exec chown otheruser {} \;
I know it's not documented in the System V manual -- I submitted an MR on this
and it will be documented in the next issue (I believe).
More information about the Comp.unix.wizards
mailing list