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.
So i thought about writing up a script that would list all directories within /data/exports/ and those that are not numbers, do a rm -R on it...but i can't seem to get it right...
Yogesh, i've been using the find command along with the -type d option which works fine, but i need to figure out a way to only rmdir the directories that are not numerical years. Is there a way, to filter out the directories named 2000, 2001 etc and delete all the rest? I can't seem to get it working...
Technically the way i thought of doing it was using a if "not numerical" then rmdir -fR ? But how do i write this "if"?
The grep removes any line containing a number in the last component of the path name. Maybe you should run it with "xargs echo rm" first just to see that it does what you want.
You could also play around with find -type d \! -name '*[0-9]*'