![]() |
|
|
grep unix.com with google
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Our Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
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? |
|
|||
|
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 | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
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 |