bash - Dividing double-precision shell variables in a shell script -
i working shell scripting on linux.
i have 2 double variables , want divide them, , put results variable.
i tried following (does not work) :
#!/bin/bash a=333.33 b=111.11 c="$a / $b" | bc -l although following work:
#!/bin/bash a=333.33 b=111.11 echo "$a / $b" | bc -l what doing wrong?
thanks matt
pipes work on output streams, and:
c="$a / $b" | bc -l does not send "$a / $b" output stream, instead sends eof.
you can this:
c=$(echo "$a / $b" | bc -l) to result c.
Comments
Post a Comment