The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to listout the files based on group by the date...? psiva_arul UNIX for Dummies Questions & Answers 3 04-21-2008 09:03 AM
Count of files based on date? sbasetty Shell Programming and Scripting 6 01-11-2007 03:02 PM
how to remove files with a date justintime Shell Programming and Scripting 5 09-10-2006 09:50 PM
script to view files based on date krahuliyer Shell Programming and Scripting 6 10-05-2005 04:51 AM
Moving files based on creation date dgoyea UNIX for Dummies Questions & Answers 1 06-28-2001 05:43 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-09-2005
hshapiro hshapiro is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 56
Remove files based on date

I am trying to write a shell script that will remove files in a directory based on the date. For instance, remove all files older than yesterday. Any ideas?
  #2 (permalink)  
Old 12-09-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Welcome to the forum. There is a search facility within the forum. You could start there.

Find files older than 5 days and remove tem after listing
  #3 (permalink)  
Old 12-09-2005
hshapiro hshapiro is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 56
Thanks for the advice. The mtime does not really work the way I want. It only seems to look for files older by exactly x days. If I want to remove all files older than yesterday, is something different?
  #4 (permalink)  
Old 12-09-2005
dasreboot dasreboot is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 3
man find

from the find man page:

Numeric arguments can be specified as

+n for greater than n,

-n for less than n,

n for exactly n.


so find . -mtime +2
finds all files older then 2 days old
  #5 (permalink)  
Old 12-09-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Couple that +n, -n info along with the below option.

Code:
       -newer file
              File was modified more recently than file.  -newer  is  affected
              by  -follow  only  if -follow comes before -newer on the command
              line.
Create a file by using touch. touch it with the required timestamp. And use it.

man touch
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0