[CentOS] delete directories with find and exclude other directories

Wed Feb 3 17:58:06 UTC 2016
Valeri Galtsev <galtsev at kicp.uchicago.edu>

On Wed, February 3, 2016 11:37 am, Tim Dunphy wrote:
> Hi all,
>
> I'm attempting to delete some directories and I want to be able to exclude
> a directory called 'logs' from being deleted.
>
> This is my basic find operation (without the exclusion)
>
> # find . -type d  |tail -10
> ./d20160124-1120-df8mfb/deployments
> ./d20160124-1120-df8mfb/releases
> ./d20160131-16993-vazqg5
> ./d20160131-16993-vazqg5/metadata
> ./d20160131-16993-vazqg5/deployments
> ./d20160131-16993-vazqg5/releases
> ./logs
> ./d20160203-27735-1tqbjh6
> ./d20160125-1120-1yccr9p
> ./d20160131-16993-1yf9lnc

crude thing I would do is:

find . -type d  | grep -v logs

, but that will also exclude other names containing "logs" it is like:

Semilogs2
logs4me

Thanks.
Valeri


>
> I'm just tailing the output so that you have an idea of what's going on
> without taking up the whole page. :)
>
> If I try to exlclude the logs directory with the prune command I get back
> no results.
>
> root at ops-manager:/tmp/tmp# find . -type d  -prune -o -name 'logs' -print
> root at ops-manager:/tmp#
>
> What am I doing wrong?
>
> Thanks,
> Tim
>
> --
> GPG me!!
>
> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos
>


++++++++++++++++++++++++++++++++++++++++
Valeri Galtsev
Sr System Administrator
Department of Astronomy and Astrophysics
Kavli Institute for Cosmological Physics
University of Chicago
Phone: 773-702-4247
++++++++++++++++++++++++++++++++++++++++