The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Finding modified File List after the chosen date in Korne Shell... marconi Shell Programming and Scripting 2 01-22-2008 02:27 AM
Finding only those files older than 2 hours mh53j_fe UNIX for Dummies Questions & Answers 2 07-01-2005 06:33 AM
Finding modified files rhayabusa UNIX for Dummies Questions & Answers 2 12-16-2004 10:48 AM
finding date and time after 3 hours svannala High Level Programming 2 09-07-2003 08:07 PM
Finding files older than 2 hours ianf Shell Programming and Scripting 1 05-27-2002 07:51 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-19-2008
Registered User
 

Join Date: Feb 2006
Posts: 40
finding the file which is modified within last 2 hours

hi,
I want to find a file which is modified within last 2 hours
i am using sun-os
i tried find . -name <filename> -mmin 120

i found that mmin option is not supported in sun-os is there any other alternative option

suggestions welcome

thanks in advance
Reply With Quote
Forum Sponsor
  #2  
Old 03-20-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,294
You need perl, python or C - here is perl
Code:
#!/bin/ksh
secs()
{
	perl -e ' 
			 $mtime = (stat $ARGV[0])[9];
			 $diff = time() - $mtime;
			 if ($diff > ( $ARGV[1] * 3600 )) 
			 {
			     print "1";	
			 }
			 else
			 {
			     print "0";	
			 }
			' $1  $2
}
hours=2
for file in `ls *.pl`
do
	older=$(secs $file $hours)
	if [[ $older -eq 1 ]] ; then
	   echo "$file is older"
	else
	   echo "$file is not older"
	fi   
done
Reply With Quote
  #3  
Old 03-20-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Quote:
Originally Posted by trichyselva View Post
hi,
I want to find a file which is modified within last 2 hours
i am using sun-os
i tried find . -name <filename> -mmin 120

i found that mmin option is not supported in sun-os is there any other alternative option

suggestions welcome

thanks in advance
please try the mtime option. check the man page of find.
Reply With Quote
  #4  
Old 03-21-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,907
With zsh:

Code:
print -l **/*(.mh-2)
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 02:56 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0