Re: delete directories with find and exclude other directories

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



On 2/3/2016 12:37 PM, Tim Dunphy wrote:
> I'm attempting to delete some directories and I want to be able to exclude
> a directory called 'logs' from being deleted.

Since you can't have a file and a directory named "logs" in the same directory at the same time (that I know of), you could turn on bash's extended globbing.

$ shopt -s extglob
$ rm -rf !(logs)

That will only preserve the top-level entity named logs, though.  If there's a "logs" in a subdirectory, it'll get deleted.

-- 
-Chris
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://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