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?
Conservative. Idaho. Software engineer. Historian. Trying to prevent Idiocracy from becoming a documentary.
Email complaints/requests about copyright infringement to clayton @ claytoncramer.com. Reminder: the last copyright troll that bothered me went bankrupt.
Thursday, April 18, 2019
Subscribe to:
Post Comments (Atom)
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.