[CentOS] delete directories with find and exclude other directories
Chris Beattie
cbeattie at geninfo.com
Wed Feb 3 19:11:13 UTC 2016
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
More information about the CentOS
mailing list