Perhaps you could tell us more precisely how and where the folder is created, does it matter if it is not empty, do you want only folders to be deleted if they match the day of the running deletion script, will it also run automatically and what is your default shell.
The more information a script has about the data it encounters, the smaller the chance of unpredictable behaviour.
For example, I'm sure you wouldn't want /home/userx/Thurman_Electronics_acct_data or /home/monica/Monicas_address_book or /home/usery/Mail/Sun-Micro deleted!
This is what my current script does: In /home/BACK-UP dir, cron runs a script that backs up server info and transactions every day. It first creates a dir like this: mkdir ""`date +"%a"` and backs up every thing in ""`date +"%a"` dir.
What I want is not more than a weeks backup so I need to create a script [where i need help] that will search /home/BACK-UP dir for dir that matches present day and delete it.
eg. After a week, I'll have Mon, Tue, Wed ... dirs with backups in them. Starting Mon, it will delete Mon dir and so on.
I can get cron to first run the script that deletes Mon dir and then run the backup script. What I cannot figure out is hoe to delete the dirs matching present day.