floating-point operations with bash

后端 未结 3 1917
无人共我
无人共我 2021-02-09 05:24

how can I transform the string \"620/100\" into \"6.2\" in a bash script

The context of my question is about image processing. EXIF data are coding the focal length in f

3条回答
  •  眼角桃花
    2021-02-09 05:46

    bash doesn't support floating point.

    You could use bc:

    $ echo "50/10" | bc -l
    5.00000000000000000000
    $ echo "scale=1; 50/10" | bc -l
    5.0
    

提交回复
热议问题