Sorry guys, I need to take it a step further and am hitting a wall at the moment;
I need to take two results (from you examples), compare them and get a final result. What I have thus far is; operation() { echo >> $LOG echo Running operation>> $LOG for i in a b do mkdir $DIR/dir$i cd $DIR/dir$i date1=$SECONDS operation date2=$SECONDS interval$i=$(($date2 - $date1)) #1st & 2nd errors echo Operation took $interval second. >> $LOG rm -rf * cd / umount $DIR done echo The 2nd time difference should be quicker than the 1st >> $LOG interval=$(($interval8 - $interval2048)) >> $LOG #3rd error if test 5 -gt "$interval"; then echo fail else echo pass fi } I'm getting the errors; ./file.sh: line x: intervala=1: command not found ./file.sh: line x: intervalb=1: command not found ./file.sh: line x: - : syntax error: operand expected (error token is " ") It seems so simple in my head, but I don't know how to execute it... Any help would be greatly appreciated. Thanks Matthew. Matthew_S wrote: > > Thanks Paul and Chet; > > They both do the same thing and that's exactly what I was looking for. > > Thanks again, > > Matthew. > > > Chet Ramey wrote: >> >> Paul Jarc wrote: >> >>> date1=`perl -e 'print time()'` >>> ... >>> date2=`perl -e 'print time()'` >>> interval=`expr "$date2" - "$date1"` >> >> This general approach can be used without invoking any external programs: >> >> date1=$SECONDS >> ... >> date2=$SECONDS >> interval=$(( $date2 - $date1 )) >> >> Chet >> -- >> ``The lyf so short, the craft so long to lerne.'' - Chaucer >> Live Strong. No day but today. >> Chet Ramey, ITS, CWRU [EMAIL PROTECTED] >> http://cnswww.cns.cwru.edu/~chet/ >> >> >> _______________________________________________ >> Bug-bash mailing list >> Bug-bash@gnu.org >> http://lists.gnu.org/mailman/listinfo/bug-bash >> >> > > -- View this message in context: http://www.nabble.com/Timing-an-operation-tf3809131.html#a10800402 Sent from the Gnu - Bash mailing list archive at Nabble.com. _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash