LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 02-25-2009, 03:35 AM   #1
learn2bperfect
LQ Newbie
 
Registered: Feb 2009
Distribution: Redhat
Posts: 6

Rep: Reputation: 0
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
 
Old 02-25-2009, 04:16 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,505

Rep: Reputation: 1078Reputation: 1078Reputation: 1078Reputation: 1078Reputation: 1078Reputation: 1078Reputation: 1078Reputation: 1078
Try /proc; and I think you'll need another "-o" after the prune (before the left bracket)
 
Old 02-25-2009, 05:03 AM   #3
learn2bperfect
LQ Newbie
 
Registered: Feb 2009
Distribution: Redhat
Posts: 6

Original Poster
Rep: Reputation: 0
Thumbs up

Following command solved the problem
find / -xdev -path /proc -prune -o \( -perm -04000 -o -perm -02000 \)\ -type f
 
Old 02-25-2009, 05:09 AM   #4
bernihard
LQ Newbie
 
Registered: Feb 2009
Location: Spain
Distribution: CentOS 5.2
Posts: 13

Rep: Reputation: 2
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
 
Old 02-26-2009, 12:22 AM   #5
learn2bperfect
LQ Newbie
 
Registered: Feb 2009
Distribution: Redhat
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Single find command to find multiple files? thok Linux - Newbie 7 01-31-2009 05:45 PM
find using -prune and -size sharky Programming 4 09-24-2008 05:14 AM
Solaris + find -prune command puzzle dazdaz Solaris / OpenSolaris 1 02-28-2008 07:29 PM
Use the prune option in find command frznchckn Linux - General 1 06-06-2007 08:18 PM
How to prune more than one directory using GNU find judgex Programming 1 06-04-2006 12:50 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration