[SunHELP] script thats test on timestamp

Doug McLaren dougmc at frenzy.com
Fri Jan 3 17:45:39 CST 2003


On Tue, Dec 17, 2002 at 03:54:47PM +0100, Simon Jespersen wrote:

| I need at script that test the time stamp on a normal text file. 
| 
| if [ timestamp > 60 min ] ; then
|     do something here
| fi
| 
| Does anyone have this small procedure in normal ksh or sh 

I don't think the bourne shell can do that.  Don't think that ksh can
either ...

If you have gnu find --

   if `find find -mmin +60 > /dev/null`; then
      do something here
   fi

but that only works with gnu find.

If you have perl, you could do this ...

   SECONDS=`perl -e 'print (time - (stat($ARGV[0]))[9])' file-to-test`
   if [ $SECONDS > 3600 ]; then
      do something here
   fi

I'll assume that you know what the three different time stamps for a
given file are (mtime, ctime, atime) ...

-- 
Doug McLaren, dougmc at frenzy.com                    Gravity is a cruel mistress


More information about the SunHELP mailing list