problem deleting date-time stamped file in a directory


 
Thread Tools Search this Thread
Top Forums Programming problem deleting date-time stamped file in a directory
# 1  
Old 05-13-2004
problem deleting date-time stamped file in a directory

I have a number of files of the format filename.xfr_mmddyy_%H%M%S which i get in a specified directory daily. Now i want to search in the specified directory & delete the files which are more than 2 days old .So I use a command
find $DIR/backup/* -ctime +2 -exec rm -f {} \;
But after executing this today say on May 11 ,I still have many files of May 7 & May 8.
Kindly tell me what this ctime exactly does and please tell me how I can solve this problem.

Thanks
Dharmesh Tripathi
# 2  
Old 05-13-2004
Try using -mtime rather than -ctime. "ls -l" shows mtime. "ls -lc" would show ctime. You're looking at one timestamp and testing on another.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Average of multiple time-stamped data every half hour

Hi All, Thank you for reading through my post and helping me figure out how I would be able to perform this task. For example: I have a list of continuous output collected into a file in the format as seen below: Date...........Time........C....A......... B ==========================... (5 Replies)
Discussion started by: terrychen
5 Replies

2. Shell Programming and Scripting

How to extract latest file by looking at date time stamp from a directory?

hi, i have a Archive directory in which files are archived or stored with date and time stamp to prevent over writing. example: there are 5 files s1.txt s2.txt s3.txt s4.txt s5.txt while moving these files to archive directory, date and time stamp is added. of format `date... (9 Replies)
Discussion started by: Little
9 Replies

3. Shell Programming and Scripting

Monitoring for specific date stamped files before and after midnight

Hi Guys, I am having a brain freeze.... I want to monitor a directory for a time stamped file on a sol 10 system in bash or ksh, the files will come in looking like this.. randomfile.DDMMYY.rpt The problem i am having is the file can come in before or after midnight, the file will... (5 Replies)
Discussion started by: twinion
5 Replies

4. Shell Programming and Scripting

Date time problem

Hi Guys, I have a file a.txt Start Date/Time End Date/Time from Prob_Dura. ----------------- ----------------- ----- ------ 20090525 23:58:59 20090526 00:00:00 machine1 000051 20090525 23:58:09 20090526 00:00:11 machine2 000150 The perl or shell script can: 1. remove... (4 Replies)
Discussion started by: jimmy_y
4 Replies

5. UNIX for Dummies Questions & Answers

How to always display date/time regardless of directory?

I found via Google a way to show the date and time stamp once I log in. However, whenever I cd to another directory it doesn't display the correct path. Here are the relevant parts from my .kshrc : unset _h _m _s eval $(date "+_h=%H ;_m=%M ;_s=%S") ((SECONDS =... (3 Replies)
Discussion started by: Mike F.
3 Replies

6. Shell Programming and Scripting

Deleting the file only to all the directory and sub directory

I need the unix command or shell script to delete all the file in current directory and sub directory. (7 Replies)
Discussion started by: kingganesh04
7 Replies

7. Shell Programming and Scripting

problem with displaying date and adding time

Hi, I have a log file with contents like 81.49.74.131 - - 81.49.74.131 - - 116.112.52.31 - - 116.112.52.31 - - I need an output like this 81.49.74.131 14/Sep/2008 Time duration: 00:06:00 116.112.52.31 15/Sep/2008 Time duration: 00:00:01 Please anyone suggest a script for this.... (1 Reply)
Discussion started by: FuncMx
1 Replies

8. Shell Programming and Scripting

Processing a log file based on date/time input and the date/time on the log file

Hi, I'm trying to accomplish the following and would like some suggestions or possible bash script examples that may work I have a directory that has a list of log files that's periodically dumped from a script that is crontab that are rotated 4 generations. There will be a time stamp that is... (4 Replies)
Discussion started by: primp
4 Replies

9. Shell Programming and Scripting

deleting multiple records from a huge file at one time

I have a very big file of 5gb size and there are about 50 million records in there. I have to delete the records based on recrord number that I know fromoutside with out opening the file. The record numbers are very random like 5000678, 7890005 etc. Can somebody let me know how i can... (5 Replies)
Discussion started by: dsravan
5 Replies

10. Shell Programming and Scripting

How do i collect date and time for list of files in a directory

How do i collect date and time for list of files in a directory using AWK Command (4 Replies)
Discussion started by: laknar
4 Replies
Login or Register to Ask a Question