I want to find files in the /tmp
directory. I use -path
and -prune
to exclude the subdirectory sgid
from the results.
So I do something like this:
[root@ tmp]# find ./ -path ./sgid -prune -o -name 'foo*'
./sgid
./foo1
./dir1/foo2
./sgid0/foo1
./sgid0/foo
./sgid0/foo2
However the output still contains the sgid
subdirectory, which is not what I expect.
But when i do like the following:
[root@ tmp]# find ./ -path ./sgid -prune -o -name 'foo*' -print
./foo1
./dir1/foo2
./sgid0/foo1
./sgid0/foo
./sgid0/foo2
The output matches my expectation. Why does the command have to include the -print
option?