#!/bin/bash
#Program: time spent
#set -x
function timespent() {
date_begin=$1
date_end=$2
declare -i date_total_s=$(($date_end-$date_begin))
declare -i date_d=$(($date_total_s/60/60/24))
declare -i date_h=$(($(($date_total_s-$date_d*60*60*24))/60/60))
declare -i date_m=$(($(($date_total_s-$date_d*60*60*24-$date_h*60*60))/60))
declare -i date_s=$(($date_total_s-$date_d*60*60*24-$date_h*60*60-$date_m*60))
echo " The program have spent: $date_d days,$date_h hours,$date_m minutes,$date_s seconds."
}
declare -i date_s=`date +%s`
sleep 2
declare -i date_e=`date +%s`
timespent $date_s $date_e
阅读(2647) | 评论(0) | 转发(0) |