Sample Header Ad - 728x90

I keep receiving command not found when I try to run my code in bash

3 votes
4 answers
4156 views
I am trying to write a code that will calculate the radius and area of a circle using pi and the circumference. When I try to run my code, I receive an error message that says
main.sh: line 5: bc: command not found
main.sh: line 7: bc: command not found
Could you please advise me on where I went wrong, and help me to fix my code? The code: #!/bin/bash pi=3.14; circumference=5; echo "$circumference" radius=$(echo "$circumference" \* 2 \* "$pi" |bc -l); echo "$radius" area=$(echo "$pi" \* "$radius" \* "$radius" |bc -l); echo "$area" echo "The radius of a circle is $radius"; echo "The area of a circle is $area"; exit
Asked by user445702 (51 rep)
Dec 9, 2020, 06:21 PM
Last activity: Jan 29, 2023, 09:34 PM