Deleting / finding files older than X days missess a day

Hi

When trying to find and delete files which are, say, 1 day, the find command misses a day. Please refer the following example.

xxxd$ find . -type f -ctime +1 -exec ls -ltr {} \;
total 64
-rw-rw-r-- 1 oracle xxxd 81 Apr 30 11:25 ./ful_cfg_tmp_20080429_7.dat
-rw-rw-r-- 1 oracle xxxd 81 May 1 11:25 ./ful_cfg_tmp_20080430_8.dat
-rw-rw-r-- 1 oracle xxxd 81 May 2 11:25 ./ful_cfg_tmp_20080501_9.dat
-rw-rw-r-- 1 oracle xxxd 83 May 3 11:25 ./ful_cfg_tmp_20080502_10.dat
-rw-rw-r-- 1 oracle xxxd 83 May 4 11:25 ./ful_cfg_tmp_20080503_11.dat
-rw-rw-r-- 1 oracle xxxd 83 May 5 11:25 ./ful_cfg_tmp_20080504_12.dat
xxxd$ date
Thursday May 8 08:59:03 BST 2008

Now, the problem is, we are missing the file for May 06 (Its present in the dir. 'find' is not fetching it.)

Could some one point what was the problem with the command. Previously we tried with mtime and atime, and nothing helped us either. :confused:

Can you please give the output of ls -l for the May 6 file you want to list? May be we can get some clue from that.

This is the May 06 th file 'find' is missing.

-rw-rw-r-- 1 oracle xxxd 83 May 6 11:25 ./ful_cfg_tmp_20080505_13.dat

And when I tried with this it works, but is there a single command for that?

find . -type f -ctime +1; find . -type f -ctime 1

There should be a single command for this.

Got it myself.

find . -type f \( -ctime +1 -o -ctime 1 \)

This command works perfectly for my requirement. :slight_smile: