-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux bc Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to bc on Linux, covering Arch Linux, CachyOS, and other distributions including calculator operations, mathematical calculations, and precision arithmetic.
Arch/CachyOS:
# Install bc
sudo pacman -S bcDebian/Ubuntu:
sudo apt install bcFedora:
sudo dnf install bcBasic usage:
# Calculate
echo "5 + 3" | bc
# Output: 8Chain operations:
# Multiple operations
echo "5 + 3 * 2" | bc
# Output: 11 (follows order of operations)Interactive:
# Start bc
bc
# Then type calculations:
# 5 + 3
# 10 * 2
# quitSet precision:
# In bc:
# scale=2
# 10 / 3
# Output: 3.33Calculate from file:
# Create script
echo "5 + 3" > calc.txt
echo "10 * 2" >> calc.txt
# Run script
bc calc.txtOne-liner:
# Inline calculation
bc <<< "5 + 3"
# Output: 8Check installation:
# Check bc
which bc
# Install if missing
sudo pacman -S bcThis guide covered bc usage, calculator operations, and mathematical calculations for Arch Linux, CachyOS, and other distributions.
- expr Guide - Expression evaluation
- Bash Scripting Guide - Scripting basics
-
bc Documentation:
man bc
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.