Operating System - HP-UX
1838670 Members
5890 Online
110128 Solutions
New Discussion

deleting files with time Stamp

 
SOLVED
Go to solution
susee_sundar
Regular Advisor

deleting files with time Stamp

Hi.,

I am having More than 20000 files in my log directory..
I want to delete all the files leaving files of last 2 days..
Which switch is used with rm command for this purpose..
Or any other way to achieve this....

2 REPLIES 2
Arunvijai_4
Honored Contributor
Solution

Re: deleting files with time Stamp

Hi Susee,

You can use "find" in combination with "rm"

# rm -f `find -type f -mtime +2`
or
# find -type f -mtime +2 | xargs rm -f
or
# find -type f -mtime +2 -exec rm -f {} \;

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
susee_sundar
Regular Advisor

Re: deleting files with time Stamp

Hi Arun.,

Thx for the Immediate Response
It is working fine .