LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using find command with -prune and -xdev (https://www.linuxquestions.org/questions/linux-newbie-8/using-find-command-with-prune-and-xdev-707349/)

learn2bperfect 02-25-2009 02:35 AM

Using find command with -prune and -xdev
 
I am trying to list out files under /(root) which has sticky bit set.
But the find command should not search in /proc directory.

The command I am using is
#find / -xdev -name proc -prune \( -perm -04000 -o -perm -02000 \) -type f

This does not list anything, but when I remove -prune in the command it lists out files.

#find / -xdev \( -perm -04000 -o -perm -02000 \) -type f

Can someone help me out

syg00 02-25-2009 03:16 AM

Try /proc; and I think you'll need another "-o" after the prune (before the left bracket)

learn2bperfect 02-25-2009 04:03 AM

Following command solved the problem
find / -xdev -path /proc -prune -o \( -perm -04000 -o -perm -02000 \)\ -type f

bernihard 02-25-2009 04:09 AM

Look at the find manual, and you'll see:

-prune If -depth is not given, true; if the file is a directory, do not descend into it.
If -depth is given, false; no effect.

That's why you see nothing.

if you want to avoid the /proc folder, you can simply use a pipe and grep your results:

find / -xdev \( -perm -04000 -o -perm -02000 \) -type f | grep -v ^/proc

learn2bperfect 02-25-2009 11:22 PM

I dont want find itself to not look at /proc directory, because you never know when a process exits and if find is searching in that directory(/proc/<pid>) then it will give errors.
The command that I posted solved the problem.


All times are GMT -5. The time now is 09:09 AM.