Top "Bc" questions

bc is an arbitrary precision calculator language used in shell scripting.

How to assign an output to a shellscript variable?

How to assign this result to a shell variable? Input: echo '1+1' | bc -l Output: 2 Attempts: (didn't work) #!bin/…

shell pipe bc
Floating point results in Bash integer division

I have a backup script on my server which does cron jobs of backups, and sends me a summary of …

bash bc
Bash Scripting and bc

I'm trying to write a bash script and I needed to do some floating point math. Basically I want to …

bash scripting sh bc
How do I get bc(1) to print the leading zero?

I do something like the following in a Makefile: echo "0.1 + 0.1" | bc (in the real file the numbers are dynamic, of …

bash unix bc
How to get bc to handle numbers in scientific (aka exponential) notation?

bc doesn't like numbers expressed in scientific notation (aka exponential notation). $ echo "3.1e1*2" | bc -l (standard_in) 1: parse error but …

bash numeric floating-accuracy bc
How do I calculate the log of a number using bc?

This is the first time I am using bc. I want to calculate the log (base 10) of a number. How …

unix bc
Hex to Binary conversion in bash

I'm trying to convert a series of bytes from hex to bin using bash. but I keep getting (seemingly random) "(…

bash binary hex bc
bc is ignoring scale option

I can't figure out why bc tool sometimes ignores the scale option. Here is an example: > echo 'scale=2; 2.777 - 1.4744…

linux bash bc
how to pipe bc-calculation into shell variable

I have a calculation on a Linux shell, something like this echo "scale 4;3*2.5" |bc which gives me an result, now …

linux shell variables bc
bc and its ibase/obase options:

I stumbled over a curious bug, I think: I tried to read "512" as a number to base 6, and output it …

base bc