Re: find troubles

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On 10/28/2014 5:32 PM, Robert Nichols wrote:
On 10/28/2014 04:00 PM, Tim Dunphy wrote:
Hey guys,

  Sorry not sure what's wrong with this statement. I've tried a few
variations of trying to exclude the /var/www directory.


[root@224432-24 apr-1.5.1]# find / -name "*httpd*" -type d \( ! -name www \)
/usr/lib/httpd
/usr/lib64/httpd
/var/www/vhosts/johnnyenglish/httpdocs
/var/www/lpaddevbkp/alchemist/namespace/system-config-httpd
/var/www/lpaddevbkp/httpd

Well, no name that matches "*httpd*" will also match "www", so that last
term will never match.  What you want is the "prune" action:

      find / -name www -prune -o -name "*httpd*"

Or use -path instead of -name.

Your original find statement should work with the -path test.

find / -name "*httpd*" -type d \( ! -path /var/www \)

but combining it with -prune is more efficient since it excludes the whole directory tree instead of individually excluding each file.

find / -path /var/www -prune -o -name "*httpd*"

--
Bowie
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux