#!/bin/sh
before="$(date +%s)"
echo $before
sleep 5
Ymd="$(date '+%Y%m%d')"
echo $Ymd
after="$(date +%s)"
echo $after
elapsed_seconds="$(expr $after - $before)"
echo Elapsed time for code block: $elapsed_seconds
#!/bin/sh
before="$(date +%s)"
echo $before
sleep 5
Ymd="$(date '+%Y%m%d')"
echo $Ymd
after="$(date +%s)"
echo $after
elapsed_seconds="$(expr $after - $before)"
echo Elapsed time for code block: $elapsed_seconds
Nice site.
A different look of the expr line.
((elapsed_seconds=after – before))
//Jadu, http://unstableme.blogspot.com