elapsed time

Display the elapsed time

$ export data_ini = `date +'%s'`; echo $data_ini
1292417961
$ export data_final = `date +'%s'`; echo $data_final
1292418079
$ ((temps = data_final - data_ini)); echo $temps
118
$ echo $((data_final - data_ini))            #total seconds
118
$ echo $(((data_final - data_ini) / 60))   #extract minutes
1
$ echo $(((data_final - data_ini) % 60))  #remainder seconds
58

:smiley:

ksh93 has time arithmetic so the time elapsed can be calculated and displayed in any units. time and timex tell you the elapsed time for a command. I wrote some simple C programs to give me other time bits: microsecond execution time, microsecond real time, absolute, start-relative or delta gregorian or fractional second time of each line of an output stream. Calendar/time stuff can be real neat. Hint: if you start your personal epoch after a leap day, like on March 1, 1968, the leap day is automatically calculated as the left over days after you subtract the full leap sets, years, months 3-12, 1 from the time. Handily, 2000 yas a leap year, so simple leap logic works until 2100-02-28!