Using Bc in Shell Scripts
bc can be used non-interactively, with input via a pipe. This is useful inside shell scripts. For example:
$ result=$(echo "scale=2; 5 * 7 / 3;" | bc) $ echo $result 11.66In contrast, note that the bash shell only performs integer arithmetic, e.g.:
$ result=$((5 * 7 /3)) $ echo $result 11Read more about this topic: Bc Programming Language
Famous quotes containing the word shell:
“There are no small number of people in this world who, solitary by nature,
always try to go back into their shell like a hermit crab or a snail.”
—Anton Pavlovich Chekhov (18601904)
Related Phrases
Related Words