Home » Infrastructure » Unix » delete old files
delete old files [message #246645] Thu, 21 June 2007 09:36 Go to next message
Koolwant
Messages: 49
Registered: June 2007
Location: new jersey
Member
Hey Masters

I want to delete files older than 7 days

The command

find . mtime +7 -exec rm {} \;

works in linux

can somebody tell me the similar command in unix.

Thanks in advance.

Kool
Re: delete old files [message #246651 is a reply to message #246645] Thu, 21 June 2007 09:43 Go to previous messageGo to next message
ThomasG
Messages: 3212
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
It should be exactly the same.
Re: delete old files [message #246668 is a reply to message #246651] Thu, 21 June 2007 10:56 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
find . -mtime +7 -exec rm {} \;


i=0
for FILE in `find /my-path/logs -name '*.log' -mtime +7 -print`
do
#       echo "Deleting $FILE ..."
        rm -f $FILE
        ((i=i + 1))  
done
echo "Deleted $i files"
Re: delete old files [message #246764 is a reply to message #246645] Thu, 21 June 2007 16:15 Go to previous message
Koolwant
Messages: 49
Registered: June 2007
Location: new jersey
Member
Thanks Andrew n Thomas,

I really appreciate your help.

Regards

Kool
Previous Topic: Badrecord Check in korn shell script
Next Topic: oracle forms with solaris 10
Goto Forum:
  


Current Time: Fri Nov 22 04:19:36 CST 2024