The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-01-2009
Registered User
 

Join Date: Dec 2009
Posts: 1
Question Delete Files Based on Datetime Stamp

I have a Unix directory, let's call it /home/id for example purposes. It contains the following files: oldfile.txt.20091101, oldfile.txt.20091102, oldfile.txt.20091103, etc.

I am trying to create a Korn Shell script that will go to /home/id and delete any oldfile.txt that has a datetime stamp that is older than 14 days from the current date.

I am not sure of the best way to accomplish this. Any suggestions?
  #2 (permalink)  
Old 12-01-2009
Registered User
 

Join Date: Jan 2009
Location: Va. Beach
Posts: 76

Code:
find /home/id -name "oldfile.txt.*" -mtime +14 -exec rm {} \;

find only works on multiples of x*24 hours (where x = days) so a file less than 14 days old, say 13 days 23 hours 59 minutes and 59 seconds at the time of your find command will not be deleted.
Sponsored Links
Reply

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
doubt reg time stamp in files. rogerben SUN Solaris 6 03-16-2009 11:50 PM
awk to print files in a dir between the given time stamp Arunprasad Shell Programming and Scripting 3 11-14-2008 05:28 PM
How to search for files based on the time stamp sunny_03 UNIX for Dummies Questions & Answers 1 02-12-2008 09:45 AM
Need to delete the files based on the time stamp of the file samudha UNIX for Dummies Questions & Answers 2 06-20-2007 08:02 AM
How to Zip the files from date Stamp to end date Stamp redlotus72 UNIX for Dummies Questions & Answers 1 12-08-2006 06:29 PM



All times are GMT -4. The time now is 02:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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