#!/bin/bashstart=$(date +%s)# 用需要计时的程序将下面这句替换掉
sleep 100;end=$(date +%s)
take=$(( end - start ))
echo Time taken to execute commands is ${take} seconds.let min=${take}/60
let left1=${take}-$(( ${min} * 60 ))echo That is ${min} minutes and ${left1} seconds.let h=${take}/3600
let left2=${min}-$(( ${h} * 60 ))echo That is ${h} hours and ${left2} minutes.
输出
里面用到了两种linux下的四则运算 let 以及 ${{}}
参考blog shell(7):四则运算