I have a script where I keep time of when I start and finish. This code works on Linux, but not on my MacOS Sierra v 10.12.6
start=`date +"%a %b %d %Y %r"`
end=`date +"%a %b %d %Y %r"`
elapsed_time=`date -d @$(( $(date -d "$end" +%s) - $(date -d "$start" +%s) )) -u +'%H:%M:%S'`
The error I get is:
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
-bash: - : syntax error: operand expected (error token is " ")
Is there a way to change this so that it works on my Mac?