Bash script to calculate time elapsed

后端 未结 10 1567
被撕碎了的回忆
被撕碎了的回忆 2021-01-29 22:03

I am writing a script in bash to calculate the time elapsed for the execution of my commands, consider:

STARTTIME=$(date +%s)
#command block that takes time to c         


        
10条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-29 22:20

    This is a one-liner alternative to Mike Q's function:

    secs_to_human() {
        echo "$(( ${1} / 3600 ))h $(( (${1} / 60) % 60 ))m $(( ${1} % 60 ))s"
    }
    

提交回复
热议问题