UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 30th, 2006, 04:43 PM
emotional_robot emotional_robot is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 53 emotional_robot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 40 m 35 sec
Reputation Power: 4
Send a message via Yahoo to emotional_robot
Need to write script

I need to write a script which can
find all the files with specific time stamp..eg
19:50

otherwise a substitute

find all the files accessed n secs ago..

I am using an AIX machine

which does not have -amin option for find command ..
It only has -atime option using which I can find files accessed n hrs ago...which is not comfortable for me...I need to find files n minutes or n seconds ago...

Any suggestions are most welcome..

Reply With Quote
  #2  
Old July 2nd, 2006, 08:40 AM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 2 m 57 sec
Reputation Power: 48
This finds the age of a file in seconds then compares it to a limit - you can change the filetime() function to do what you need
Code:
#
# check file mtime against desired max number of seconds since mtime
# usage:  filetime <filename> <seconds_max> 

filetime()
{
perl -e '
   ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
   $atime,$mtime,$ctime,$blksize,$blocks) = stat("$ARGV[0]");
   $difftime=time()-$mtime;
   if($difftime <= $ARGV[1]*1 ){
          print("1\n");
   }
   else{
     print("0\n")
   }; ' "$1" "$2"
}

find /path -mtime -2 |\
while read file
  okay=$(filetime "$file"  "3600")	
  if [ $okay -eq 1 ] ; then
  # file mtime is 3600 seconds or less 
      print "$file"
  fi
done

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Need to write script


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway