Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete files in unix

Status
Not open for further replies.

ksdh

Technical User
Oct 24, 2007
41
IN
Hi
I have a directory with hundreds of files.
I would like to delete files older than a day. How could i do this?

Would mtime work?

Thanks
 
find /path/to/dir -type f -mtime -1 | xargs rm

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How about making that:
find /path/to/dir -type f -mtime +1|xargs rm



"Proof that there is intelligent life in Oregon. Well, Life anyway.
 
OOps, good catch motoslide, I've inverted the test.
 
Which flavour of find is that Stefan?

I want to be good, is that not enough?
 
Had a feeling it might have been, Feherke!

I want to be good, is that not enough?
 
There is always -exec

Code:
find /path/to/dir -type f -mtime +1 -exec rm {} \;

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top