Next Hold Space 37

Shell arithmetic

  • expr only does integers:

           % expr 23 / 7
           3
  • No problem, the GNU shell has a builtin arithmetic operator

    • Which also does only integers:

           % echo $(( 23 / 7 ))
           3
  • No problem, we can use bc:

           % echo 23 / 7 | bc  -l
           3.28571428571428571428
  • Ah, that's better.


Next Next