Hi All,
I was exploring find command and came across -prune option which would exclude search in a mention subdirectory.
My quesry is to search all files more that 100 MB size but exclude search in a subdirectory.
I am using below command,but somehow it is not working.
Can anybody help me understand where i am going wrong.
Thanks in advance.
find /logs \( -name /logs/wu01/tmpbuild -prune \) -type f -size +1000k
find /logs \( -name /logs/wu01/tmpbuild -prune \) -a \( -type f -size +100M \) -print
-prune: If -depth is not given, true; do not descend the current direc-
tory.
If -depth is given, false; no effect.
Hi Devtakh,
Thanks for replying.
But Could you please explain that.
Is that command correct.
Actually i want to search the directory /logs without searching the sub directory /logs/wu01/tmpbuild and find all files of size more that 100 MB.
With above command i am not getting result though.
Thanks
---------- Post updated at 10:36 PM ---------- Previous update was at 10:11 PM ----------
usha $ find /logs \( -name /logs/wu01/tmpbuild -prune \) -a \( -type f -size +1000 \) -print
find: /logs/wu01/tmpbuild/xyz/abc: Permission denied
find: /logs/wu01/tmpbuild/def: Permission denied
Hi Dinjo,
Even with the code you have given,it is still searching in /logs/wu01/tmpbuild
Try this
find logs/* -prune -size +100 -print
cheers,
Devaraj Takhellambam
-name only matches against the basename, so that -name primary will never match, since forward slashes cannot occur in a basename. What you want is to use -path. Also, you need to or (-o) the tempbuild-prune related primaries or they will cause the expression evaluated by find to be false for all non-pruned pathnames (meaning find will never match anything).
find /logs \( -path /logs/wu01/tmpbuild -prune \) -o \( -type f -size +1000k \)
Regards,
Alister
Hi Devraj and Alister,
Thanks a lot to both of you.
The solution
find /logs \( -path /logs/wu01/tmpbuild -prune \) -o \( -type f -size +1000k \)
Worked for me..
Cheers
Usha