|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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.. |
|
#2
|
|||
|
|||
|
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
|
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Need to write script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|