The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 05-04-2007
jim mcnamara jim mcnamara is offline
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,373
try something like this:
Code:
#!/bin/ksh
# tdiff.sh 


tdiff()
{
perl -e '
   ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
   $atime,$mtime,$ctime,$blksize,$blocks) = stat("$ARGV[0]");
   $difference = time - $mtime;
   print $difference;
   ' "$1"
}

secs=$(tdiff "$1")
minutes=$secs/60
if [[ $minutes -le 15 ]] ; then
    echo "$1 is 15 minutes old or less"
else
    echo "$1 is older than 15 minutes"    
fi
Reply With Quote