If I perform the following:
mkdir /tmp/test
sudo mkdir /tmp/test/test2
sudo chmod 700 /tmp/test/test2
cd /tmp/test
I would expect find ./ -not -path "*"
to determine that test2 matches the not path rule, which should exclude it from being walked at all. However, I get find: ‘./test2’: Permission denied
implying that find
is attempting to walk the directory irrespective of the rule.
If I run the command with sudo, the directory is not listed, meaning the exclude rule is working, but is applied to output of an initial search, rather than being an explore conditional during the initial root.
I'm trying to achieve a root filesystem walk while excluding certain problematic directories, such as network filesystem mounts which cost considerable time, so I would like to direct find not to explore sub-directories as to reduce the total execution time.
How can I achieve this?
find ./ -not -path "*"
to determine that test2 matches the not path rule, which should exclude it from being walked at all." – Things do not work this way, but IF you expected this then you should have expected excluding./
from being walked at all in the first place. My point is-path "*"
is true even for./
which is tested first. I think-path "*"
evaluates as true for any path.