Bash script to calculate time elapsed

后端 未结 10 1672
被撕碎了的回忆
被撕碎了的回忆 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:19

    Try the following code:

    start=$(date +'%s') && sleep 5 && echo "It took $(($(date +'%s') - $start)) seconds"
    

提交回复
热议问题