I want to delete everything under some directory /path/to/foo, EXCEPT those sub-directories that match the meta-pattern
/path/to/foo/<DIGITS>/
For example, if the contents under /path/to/foo are initially like this:
/path/to/foo
├── 0/
│ ├── a
│ └── b
├── 232532/
├── 42
├── 73/
│ ├── d
│ └── e
├── 8xyz/
│ ├── i
│ └── j
├── _bar/
│ ├── x
│ ├── y
│ └── z
├── .baz/
│ ├── f
│ └── frobozz/
│ ├── g
│ └── h
└── quux/
└── 123/
...I want to end up with
/path/to/foo
├── 0/
│ ├── a
│ └── b
├── 232532/
└── 73/
├── d
└── e
I'm looking for a find ... -delete-based incantation, or a suitable zsh glob pattern (for rm -r), that will do this. I am using Linux.
mkdir -p 0/{a,b} 232532 73/{d,e} 8xyz/{i,j} _bar/{x,y,z} .baz/f .baz/frobozz/{g,h} quux/123; touch 42