Bash elapsed time
If you wish to calculate elapsed time when running bash scripts:
#!/bin/bash
T="$(date +%s)"
sleep 2
T="$(($(date +%s)-T))"
echo "Time in seconds: ${T}"
The +%s parameter makes the date command return a timestamp.
Then it is simply substracted (and printed).
Written by Matteo Caberlotto
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Time
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#