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 complete...
#........
ENDTIME=$(date +%s)
echo "It takes $($ENDTIME - $STARTTIME) seconds to complete this task..."

I guess my logic is correct however I end up with the following print out:

"It takes seconds to complete this task..."

Anything wrong with my string evaluation?

I believe bash variables are untyped, I would love if there is a "string to integer" method in bash nevertheless.

Edit
Report