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
You are trying to execute the number in the ENDTIME
as a command. You should also see an error like 1370306857: command not found
. Instead use the arithmetic expansion:
echo "It takes $(($ENDTIME - $STARTTIME)) seconds to complete this task..."
You could also save the commands in a separate script, commands.sh
, and use time command:
time commands.sh