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 > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Deleting files older than 7 days shezam Shell Programming and Scripting 4 07-09-2008 04:40 AM
Finding cumulative size of files older than certain days rohan076 Shell Programming and Scripting 1 04-28-2008 01:07 PM
Removing files older than 7 days texasoeb UNIX for Dummies Questions & Answers 3 04-20-2007 04:04 PM
tar files older than 30 days wfch UNIX for Dummies Questions & Answers 6 04-19-2004 04:40 AM
How can I delete files older than 7 days? odogbolu98 UNIX for Dummies Questions & Answers 3 02-26-2002 08:35 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-08-2008
guruparan18 guruparan18 is offline
Registered User
  
 

Join Date: May 2008
Location: India
Posts: 37
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.
  #2 (permalink)  
Old 05-08-2008
krishmaths krishmaths is offline
Registered User
  
 

Join Date: Sep 2006
Location: Mysore, India
Posts: 191
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.
  #3 (permalink)  
Old 05-08-2008
guruparan18 guruparan18 is offline
Registered User
  
 

Join Date: May 2008
Location: India
Posts: 37
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
  #4 (permalink)  
Old 05-08-2008
guruparan18 guruparan18 is offline
Registered User
  
 

Join Date: May 2008
Location: India
Posts: 37
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.
  #5 (permalink)  
Old 05-08-2008
guruparan18 guruparan18 is offline
Registered User
  
 

Join Date: May 2008
Location: India
Posts: 37
Got it!!

Got it myself.

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

This command works perfectly for my requirement.
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 10:20 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