Any of these will work from the shell command line. bc
is probably your most straight forward solution though.
Using bc:
$ echo "$d1 - $d2" | bc
Using awk
:
$ echo $d1 $d2 | awk '{print $1 - $2}'
Using perl
:
$ perl -E "say $d1 - $d2"
Using Python
:
$ python -c "print $d1 - $d2"
all return
4