Quote:
Originally Posted by Stephan
...I want to write a script, that will delete all directories within /data/exports/ but not the 2000,2001 and 2002 found at that first level. The 200x found within daily and etc i want gone though.
...
any thoughts, help appreciated.
|
If you were on Linux, things would have been easier by using
-mindepth option of GNU find. In this case we need first to sort the directories that aren't needed:
Code:
cd /data/exports/
find . -type d | awk '!/\.\/200*/' | xargs -p rm -r
Test it first, by removing
rm -r part, (
-p will prompt you ), to see if you have the all the
desired directories. If you need the dirs that are named as numbers 200x, then change the find part to:
Code:
find . -type d -name "200*"