Unix/Linux Shell Scripting Floating Point Division

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 !

1

2 Answers

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 )
1

Or just use the floating point support built into ksh

#!/usr/bin/ksh
v_missedvol=4003.03
v_allvolume=3003.03
v_vol_temp=$(( v_missedvol  / v_allvolume ))
echo $v_vol_temp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest