find(1) should have a primary that is true iff the current file is n levels deep in the tree. This patch implements `-depth n' and an alias `-level n' which support the usual +/- modifiers, with `-depth +-1' essentially being a noop. The reason for implementing both was a discussion with ruslan, where he preferred `-depth [[+|-]level]', while I did not like the dual syntax that depth would have, because of its definition in IEEE 1003.1. Basically this allow one to do find /usr/ports -maxdepth 2 -name Tools -prune -o -level 2 -type d -print or find /usr/ports -maxdepth 2 -name Tools -prune -o -depth 2 -type d -print which currently can only be done with something like find /usr/ports -mindepth 2 -maxdepth 2 -regex '.*/Tools/[^/]*' -prune -o -type d -print which lists all port directories without Tools (this example lists some additional files, like packages, distfiles and CVS). I'm happy with the dual syntax, and probably I should change the manpage to state that `-depth' is equivalent to `-d' and `-depth n' equivalent to `-level n' if we go with this solution, but I'm also comfortable with having only one of `-level n' or `-depth n', I just wanted to have the functionality available. Any opinions? While I'm here, fix -maxdepth when depth-first traversal is done, try: find -d /usr -maxdepth 2 Which also doesn't give you warnings if any files on level three you don't really care for are unreadable. The patches for -CURRENT and -STABLE are at: http://people.freebsd.org/~eik/patches/find-depth.5.patch MD5 (find-depth.5.patch) = 5e52ac3c090726c609a9b582f6fbc993 http://people.freebsd.org/~eik/patches/find-depth.4.patch MD5 (find-depth.4.patch) = 6b67d3ac20c8fb5857d2d54f0365b518 -OliverReceived on Mon May 17 2004 - 01:37:07 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:54 UTC