find recently modified/ updated file | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

find recently modified/ updated file

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-13-2009
lweegp lweegp is offline
Registered User
 
Join Date: Oct 2005
Last Activity: 5 August 2009, 7:45 PM EDT
Location: singapore
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
find recently modified/ updated file

hi gurus,

i would like to know how can i find logs files which were recently modified or updated?

using this command?

find . -name "*.log" -mtime ??

so what should i put for mtime?

thanks.

wee
Sponsored Links
    #2  
Old 03-13-2009
sunpraveen's Avatar
sunpraveen sunpraveen is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 26 August 2014, 3:35 AM EDT
Location: Pruthvi
Posts: 93
Thanks: 0
Thanked 1 Time in 1 Post
I don't think using find command will satisfy your requirement unless you want to recurse into directories.

If all the log files are located in the same directory, then use the below command. This will list the latest 10 files in ascending order with the latest file at the end.

If you want more log files to be displayed, use tail -<number> to display as many files as you want.


Code:
ls -lrt | tail

HTH,

Regards,

Praveen
Sponsored Links
    #3  
Old 03-13-2009
ShawnMilo ShawnMilo is offline
Registered User
 
Join Date: Jun 2006
Last Activity: 10 November 2009, 8:27 AM EST
Posts: 252
Thanks: 0
Thanked 1 Time in 1 Post
Quote:
Originally Posted by lweegp View Post
hi gurus,

i would like to know how can i find logs files which were recently modified or updated?

using this command?

find . -name "*.log" -mtime ??

so what should i put for mtime?

thanks.

wee
If you want stuff from within the last hour, use -1. If you want stuff less than five hours old, use -5. If you want to control the time by minutes instead of hours, use mmin instead.
    #4  
Old 03-15-2009
lweegp lweegp is offline
Registered User
 
Join Date: Oct 2005
Last Activity: 5 August 2009, 7:45 PM EDT
Location: singapore
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
thanks shawn for the infor. i think that should work...let me try it out.
Sponsored Links
    #5  
Old 03-15-2009
lweegp lweegp is offline
Registered User
 
Join Date: Oct 2005
Last Activity: 5 August 2009, 7:45 PM EDT
Location: singapore
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
hi shawn,

what if i need to check which files have been modify or updated over the past few days? do i use -mtime +72 for files which have been modified for the past 3 days etc?
Sponsored Links
    #6  
Old 03-15-2009
ShawnMilo ShawnMilo is offline
Registered User
 
Join Date: Jun 2006
Last Activity: 10 November 2009, 8:27 AM EST
Posts: 252
Thanks: 0
Thanked 1 Time in 1 Post
Quote:
Originally Posted by lweegp View Post
hi shawn,

what if i need to check which files have been modify or updated over the past few days? do i use -mtime +72 for files which have been modified for the past 3 days etc?
The opposite -- +72 will give you things modified more than 72 hours ago, -72 would be less than 72 hours.
Sponsored Links
    #7  
Old 03-15-2009
lweegp lweegp is offline
Registered User
 
Join Date: Oct 2005
Last Activity: 5 August 2009, 7:45 PM EDT
Location: singapore
Posts: 107
Thanks: 0
Thanked 0 Times in 0 Posts
ahh...yes should have guess its a - than a +. this should work now. thanks shawn!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find recently updated files in home directory Kain Shell Programming and Scripting 2 10-31-2008 08:20 PM
recently updated files shantanuo UNIX for Dummies Questions & Answers 6 09-27-2008 03:22 AM
which file is updated after modified the crontab entries. krishna176 Solaris 1 03-25-2007 02:42 PM
ftp most recently modified file ahmedwaseem2000 Shell Programming and Scripting 6 02-27-2007 12:22 PM
chmod command for recently modified files polka_friend UNIX for Dummies Questions & Answers 2 08-30-2006 03:25 PM



All times are GMT -4. The time now is 12:26 PM.