Search notes:

Shell: Calculate and/or display elapsed time

date +%s returns the Unix time, that is the number of seconds that have elapsed since January 1st 1970. This allows to calculate the number of elapsed seconds in a shell script in combination with expr:
T0=$( date +%s )

# do stuff (or take a nap):
sleep 10

echo time elapsed: $( expr $( date +%s ) - $T0 )

See also

Date arithmetic in a shell

Index