gswitz
asked on
UNIX KORN SHELL I need to delete files older than a given date
Can someone help me modify this script to delete items older than 5/1/2011 for example?
function DeleteOldFiles
{
LOG_LIST=`ls /usr/d/d/logs/*.*`
for LOG_FILE in ${LOG_LIST}
do
echo ${LOG_FILE} >> /usr/d/d/DeleteOldFiles.lo g
rm ${LOG_FILE}
done
echo "Finished deleting old files" >> /usr/d/d/DeleteOldFiles.lo g
}
DeleteOldFiles
function DeleteOldFiles
{
LOG_LIST=`ls /usr/d/d/logs/*.*`
for LOG_FILE in ${LOG_LIST}
do
echo ${LOG_FILE} >> /usr/d/d/DeleteOldFiles.lo
rm ${LOG_FILE}
done
echo "Finished deleting old files" >> /usr/d/d/DeleteOldFiles.lo
}
DeleteOldFiles
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
On trying this, I get...
find: incomplete statement
When I remove the -exec rm {} from the end of the statement, I do get the list of files I would like to delete.
Thanks,
G
find: incomplete statement
When I remove the -exec rm {} from the end of the statement, I do get the list of files I would like to delete.
Thanks,
G
ASKER
My last comment was to FLOW1... Arnold, I'm trying yours now.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
I can't answer your question but I may have an alternative solution:
To remove the files older then 10 days on the determined directory you could use
find /usr/d/d/logs -mtime +10 -exec rm {}