I want to list files with certain name pattern under certain directory, and excluding certain sub-directory.
find "../../" -path "../../backup" -prune -regex "\.*\.v" -print
nothing is outputted.
But by adding
find "../../" -path "../../backup" -prune -o -regex "\.*\.v" -print
I get the correct results.
or. But I don’t think there is an
or logic in my requirements, I think it should be
file name with certain pattern & under certain directory & not under certain sub-directory
Am I doing something wrong?
find man page:
-prune True; if the file is a directory, do not descend into it. If -depth is given, false; no effect. expr1 -o expr2 Or; expr2 is not evaluated if expr1 is true. The construct -prune -o \( ... -print0 \) is quite common. The idea here is that the expression before -prune matches things which are to be pruned. However, the -prune action itself returns true, so the following -o ensures that the right hand side is evaluated only for those directories which didn't get pruned (the contents of the pruned directories are not even visited, so their contents are irrelevant).