echo "scale = 4; .5/2" | bc -l
produces expected result: .2500
set x=`echo "scale = 4; .5/2" | bc -l`
executes but x is set to a blank.
set x=$(echo "scale = 4; .5/2" | bc -l)
does the same thing. Has backtick changed since 2014?
Progress. Bash variables need no spaces around the = and set is not required, or wanted. The for loop:
for y in ($(seq -f "%0.4f" $y $advanceY $endY) does not increment by .1 (the value of advanceY), but by 1. Duh: advanceY is not $advance.
This problem remains
echo "scale = 4; .5/2" | bc -l
produces expected result: .2500
x=`echo "scale = 4; .5/2" | bc -l`
executes but x is set to a blank.
x=$(echo "scale = 4; .5/2" | bc -l)
does the same thing. Has backtick changed since 2014?
The problem, I think, is "set". Just:
ReplyDeletex=`echo "scale = 4; .5/2" | bc -l`
set is a csh-ism.
ReplyDeletedropping it makes both of the next two lines work fine.
I can't duplicate your results on my machine (Fedora 30, runs bash 5.0.2).
ReplyDeleteecho $SHELL
[outputs /bin/bash]
echo $BASH_VERSION
[outputs 5.0.2(1)-release]
x=`echo "scale = 4; .5/2" | bc -l`
echo $x
[outputs .2500]
y=$(echo "scale = 4; .5/2" | bc -l)
echo $y
[also outputs .2500]
You use "set" in Windows and csh.
ReplyDeleteNot in sh or bash.