LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Find command with path and prune (https://www.linuxquestions.org/questions/linux-newbie-8/find-command-with-path-and-prune-4175431270/)

abhinav4 10-09-2012 02:13 AM

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

kooru 10-09-2012 03:10 AM

You can look at here:

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

abhinav4 10-09-2012 03:31 AM

Quote:

Originally Posted by kooru (Post 4801023)
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

kooru 10-09-2012 03:33 AM

Yes sorry i edited my post some minutes ago :)

pan64 10-09-2012 03:38 AM

why don't you try the command locate? (and grep -v "^/proc/cpuinfo")? But probably locate will automatically skip /proc

abhinav4 10-09-2012 04:03 AM

Quote:

Originally Posted by pan64 (Post 4801051)
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

colucix 10-09-2012 08:23 AM

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).

abhinav4 10-09-2012 08:33 AM

This helped me thanks colucix


All times are GMT -5. The time now is 02:02 PM.