Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

problem with find

Shell Programming and Scripting


Tags
find -mtime, mtime

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-28-2006   -   Original Discussion by braindrain
braindrain braindrain is offline
Registered User
 
Join Date: Jul 2005
Last Activity: 24 June 2008, 6:42 AM EDT
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
problem with find

Hi,
Iam having a strange problem, wandering if soneone can throw some lights.

I have statement


Code:
 find . -maxdepth 1 -name 'File1*.tsv' -mtime +1 -print

I expect the above statement to print the files older than 1 day or 24 hrs,

however it doesn't work that way. When issue above command, it displays only files that are greater than or equal to 2 days . I have a file which was created 25 hrs ago and I expect this command to display the file name as well.However it doesn't seem to be happening.

Why is this case ?

My requirement is to find files that ae more than 1 day / 24 hrs old.
Thnx

Last edited by braindrain; 03-28-2006 at 07:13 PM..
Sponsored Links
    #2  
Old Unix and Linux 03-28-2006   -   Original Discussion by braindrain
Perderabo's Unix or Linux Image
Perderabo Perderabo is offline Forum Advisor  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 26 February 2016, 12:31 PM EST
Location: Ashburn, Virginia
Posts: 9,930
Thanks: 64
Thanked 471 Times in 271 Posts
Take the file modification time in seconds and subtract the start time of the find program. This is the number of seconds in the past that the file was modified. Now divide by 86400 and discard any remainder. This is the number of days ago (as computed by the find command) that the file was modified. So the result you see is the expected result. You want:
-mtime +0

Don't feel bad. I only recently got this straight. The difference between "-time 0" and "-mtime +0" is counterintuitive. If you're not confused yet, think about "-mtime -0". Linux
Sponsored Links
    #3  
Old Unix and Linux 03-29-2006   -   Original Discussion by braindrain
braindrain braindrain is offline
Registered User
 
Join Date: Jul 2005
Last Activity: 24 June 2008, 6:42 AM EDT
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Worked like a charm Good learning, thx Perderabo!!

Last edited by braindrain; 03-29-2006 at 01:49 PM..
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find problem ygemici Shell Programming and Scripting 7 02-28-2010 11:22 PM
find problem crackthehit007 Shell Programming and Scripting 2 09-29-2009 09:00 AM
Problem with find and tar venu_nbk UNIX for Dummies Questions & Answers 2 11-20-2006 10:41 AM
Problem with `find ...` Cameron Shell Programming and Scripting 4 08-10-2005 08:24 AM
Another Find Problem sethkor Shell Programming and Scripting 6 02-24-2005 07:56 PM



All times are GMT -4. The time now is 03:41 AM.