LinuxQuestions.org
Help answer threads with 0 replies.
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 10-09-2012, 02:13 AM   #1
abhinav4
Member
 
Registered: Jun 2010
Location: India
Distribution: Fedora/Cent OS
Posts: 123

Rep: Reputation: 0
Exclamation Find command with path and prune


Quote:
[root@test ~]# find / -name cpuinfo
/proc/cpuinfo
/home/user1/cpuinfo
/var/named/chroot/proc/cpuinfo

Quote:
[root@test ~]# find / -path /proc/ -prune -name cpuinfo
[root@test ~]#
-path with -prune not working fine.
requirement:- I want to find a file named cpuinfo in all location other than /proc
 
Old 10-09-2012, 03:10 AM   #2
kooru
Senior Member
 
Registered: Sep 2012
Posts: 1,385

Rep: Reputation: 273Reputation: 273Reputation: 273
You can look at here:

http://www.linuxquestions.org/questi...d-size-671686/
http://www.linuxquestions.org/questi...delete-902604/

Last edited by kooru; 10-09-2012 at 03:30 AM. Reason: sorry i didn't read very well your question :)
 
1 members found this post helpful.
Old 10-09-2012, 03:31 AM   #3
abhinav4
Member
 
Registered: Jun 2010
Location: India
Distribution: Fedora/Cent OS
Posts: 123

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by kooru View Post
I don't understand.
If you want to find a file in all location:

find / -name cpuinfo
Yes i want to find a file in all location but also want it to exclude the location /proc while searching
 
Old 10-09-2012, 03:33 AM   #4
kooru
Senior Member
 
Registered: Sep 2012
Posts: 1,385

Rep: Reputation: 273Reputation: 273Reputation: 273
Yes sorry i edited my post some minutes ago
 
Old 10-09-2012, 03:38 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,185

Rep: Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673Reputation: 2673
why don't you try the command locate? (and grep -v "^/proc/cpuinfo")? But probably locate will automatically skip /proc
 
Old 10-09-2012, 04:03 AM   #6
abhinav4
Member
 
Registered: Jun 2010
Location: India
Distribution: Fedora/Cent OS
Posts: 123

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
why don't you try the command locate? (and grep -v "^/proc/cpuinfo")? But probably locate will automatically skip /proc
This may work but I need a generic solution which I can use for any search. Like in the above case what will happen if the file cpuinfo has multiple copies inside /proc like /proc/cpuinfo, /proc/xyz/cpuinfo, /proc/abc/cpuinfo etc
 
Old 10-09-2012, 08:23 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Code:
find / -path /proc -prune -o -name cpuinfo -print
Please, see this post for an in-depth explanation (it uses -wholename instead of -path but they are the same).
 
1 members found this post helpful.
Old 10-09-2012, 08:33 AM   #8
abhinav4
Member
 
Registered: Jun 2010
Location: India
Distribution: Fedora/Cent OS
Posts: 123

Original Poster
Rep: Reputation: 0
This helped me thanks colucix
 
  


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
[SOLVED] find command using -exec -fprintf -prune -mtime crimso Linux - General 15 05-17-2011 12:02 PM
[SOLVED] Using find and prune to not print path grail Linux - Newbie 2 01-10-2011 10:16 AM
Using find command with -prune and -xdev learn2bperfect Linux - Newbie 4 02-25-2009 11:22 PM
Solaris + find -prune command puzzle dazdaz Solaris / OpenSolaris 1 02-28-2008 06:29 PM
Use the prune option in find command frznchckn Linux - General 1 06-06-2007 07:18 PM


All times are GMT -5. The time now is 02:57 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration