I want to time in seconds for execution of shell script.
My implementation:
#!/bin/sh
START=$(date +%s)
echo $START
.
.
bla bla bla
.
.
.
END=$(date +%s)
echo $END
DIFF=($END - $START)
echo "Time difference is "$DIFF
This is showing me END time and not difference.
I cannot guess the reason why minus is not working.
Assuming you’re using
bash:You need to use double parens to do arithmetic in the shell:
Note that you don’t have to use dollar signs to read from variables inside of double parens.