Urgent Help needed...

Hi

I want to create a script which deleted files in the following folders older than 30 days. There are a particular version of files inside it to be deleted

Folders :

/files0/interfaces/ResponsysSavedList/BackInStock/EmailContent/backup
/files0/interfaces/ResponsysSavedList/SavedList/backup
/files0/interfaces/commerce/coupons/incoming/backup
/files0/interfaces/commerce/coupons/outgoing/backup

I have created the following code but it doesnt seems to be working fine :

$folder="EmailContent Recipients"
BACKUP_DEST=$APPSTORAGE/interfaces/ResponsysSavedList/BackInStock/$folder/backup

# Deleting .csv files from ResponsysSavedList older than 30 days
echo "Searching for files older than 30 days to Delete"
for $folder in $BACKUP_DEST 
do 
    find $BACKUP_DEST -name "NL_Responsys_BackInStock_*.csv" -type f -mtime +30 -print | while read FILENAME
    do
        ls -ald "${FILENAME}"
        rm -r "${FILENAME}"
    done
    echo "BACKUP_DEST incorrect or missing: ${BACKUP_DEST}"
done 

APPSTORAGE is my complete path, so dont bother about it.

The key thing is to write a single code which can delete the file from different paths and they change after folloowing a heirarchy.

try something like this..

find $BACKUP_DEST -name "NL_Responsys_BackInStock_*.csv" -type f -mtime +30 -exec rm -r {} \;

I am getting this error :

bash-3.2$ ./Test.sh -e dev
INFO: Running as admin user nlaedev01
./Test.sh: line 84: =EmailContent Recipients: command not found
Searching for files older than 30 days to Delete
./Test.sh: line 93: `$folder': not a valid identifier

Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and demanding a fast reply are not permitted in the regular forums.

For members who want a higher visibility to their questions, we suggest you post in the Emergency UNIX and Linux Support Forum. This forum is given a higher priority than our regular forums.

Posting a new question in the Emergency UNIX and Linux Support Forum requires forum Bits. We monitor this forum to help people with emergencies, but we do not not guarantee response time or best answers. However, we will treat your post with a higher priority and give our best efforts to help you.

If you have posted a question in the regular forum with a subject "Urgent" "Emergency" or similar idea, we will, more-than-likely, close your thread and post this reply, redirecting you to the proper forum.

Of course, you can always post a descriptive subject text, remove words like "Urgent" etc. (from your subject and post) and post in the regular forums at any time.

Thank you.

The UNIX and Linux Forums