Given the following files:
data/A/a.txt
data/B/b.pdf
...
date/P/whatever.log
...
data/Z/z.jpg
I would like to delete all files in the data/A/
, data/B/
, ..., data/Z/
directories except those files that are situated under one of the directories listed in the file data/dont_clean.txt
. For example, if we have data/P
listed in data/dont_clean.txt
then nothing should be touched under data/P/
, etc.
Something like:
find data/ -mindepth 2 -maxdepth 2 -type f -not -path {listed in data/dont_clean} -delete
Of course it is not a valid command.
I have also tried variants of
find data/ -mindepth 2 -maxdepth 2 -type f -exec grep data/dont_clean.txt '{}' \;
but I only created either an invalid command or I had no idea why I got the output I did.
I am using bash on Ubuntu 12.10
data/
directory tree, see the-mindepth 2 -maxdepth 2
flags I am passing tofind
.