I am trying to write a ksh script using the case statement to select certain directories to remove. The directories that I am looking for are in the following format 2008-10-10. I want to exclude all other files/directories that contain anything other the 4 digit year,a dash, 2 digit month, a dash and 2 digit day. I tried the following but it did not work.
case $i in
*[A-Z|a-z|.])
break
;;
*[0-9]|[-])
echo "i is " $i
;;
esac
This regex also check for valid dates as best it can. Meaning, it doesn't check for leap year or stuff like 2008-02-31. To do that, I would suggest you write a more sophisitcated function for that. But this one-liner will be sufficient for most of the stuff you want.