Unix/linux shell scripting floating point division

5,670

You have a small syntax error. there may be no space between v_vol_tem= and $(echo ...

try

v_vol_temp=$(echo "$v_missedvol / $v_allvolume" | bc -l )
Share:
5,670

Related videos on Youtube

VRVigneshwara
Author by

VRVigneshwara

Updated on September 18, 2022

Comments

  • VRVigneshwara
    VRVigneshwara over 1 year

    I have to divide two floating point values and store it in variable. My code below v_missedvol=4003.03 v_allvolume=3003.03 v_vol_temp= $(echo "$v_missedvol / $v_allvolume" | bc -l )

    the result that I get is

    -ksh: =1.33299700635691285135: not found [No such file or directory]
    

    further , I need the value to be stored as

    v_volume_total=1.3329 *100
    

    Please help with this , Thanks !

    • Slizzered
      Slizzered about 9 years
      Please clarify what you mean with the last line. Do you need to store the result of 1.3329*100? do you need to truncate the result before multiplication? Do you want to store the actual formula "1.3329 *100"?
  • Slizzered
    Slizzered almost 9 years
    @VIGNESH12990 if the answer solved your problem, please consider marking it as the correct answer