I have a calculation on a Linux shell, something like this
echo "scale 4;3*2.5" |bc
which gives me an result, now I like to pipe the result of this calculation into an Variable so that I could use it later in another command,
piping into files work, but not the piping into variables
echo "scale=4 ; 3*2.5" | bc > test.file
so in pseudo-code i'm looking to do something like this
set MYVAR=echo "scale=4 ; 3*2.5" | bc ; mycommand $MYVAR
Any ideas?
You can do (in csh):
set MYVAR=`echo "scale 4;3*2.5" |bc`
or in bash:
MYVAR=$(echo "scale 4;3*2.5" |bc)