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.
"And we know that all things work together for good to them that love God, to them who are the called according to his purpose." -- Rom. 8:28
Pages
▼
Thursday, April 21, 2022
Bash/bc
y=1.0
y=`echo 'y +0.5'|bc -l`
should set y to 1.5. Right? $y is not recognized by bc. y seems to stay 0
Bash variable substitution doesn't happen in '-quoted strings.
ReplyDeleteUse:
y=1.0
y=`echo "$y +0.5"|bc -l`
This resulted in 1.5 for me:
ReplyDeletey=1.0; y=$(echo "$y+0.5" | bc -l ); echo $y