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 |
Try /proc; and I think you'll need another "-o" after the prune (before the left bracket)
|
Following command solved the problem
find / -xdev -path /proc -prune -o \( -perm -04000 -o -perm -02000 \)\ -type f |
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 |
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 01:25 AM. |