Simple Calculator - Bash Typing CST Test
Loading…
Simple Calculator — Bash Code
Performs basic arithmetic operations using functions.
add() { echo $(( $1 + $2 )); }
subtract() { echo $(( $1 - $2 )); }
multiply() { echo $(( $1 * $2 )); }
divide() { echo $(( $1 / $2 )); }
echo "Add 5 + 3: $(add 5 3)"
echo "Subtract 5 - 3: $(subtract 5 3)"
echo "Multiply 5 * 3: $(multiply 5 3)"
echo "Divide 6 / 2: $(divide 6 2)"Bash Language Guide
Bash (Bourne Again SHell) is a Unix shell and command language widely used for automation, scripting, DevOps, system administration, and shell-based application workflows. It is the default shell on most Linux systems and offers powerful command-line capabilities.
Primary Use Cases
- ▸System automation
- ▸Server maintenance scripts
- ▸DevOps & CI/CD pipelines
- ▸File management & text processing
- ▸Docker and container orchestration
- ▸Environment setup
- ▸Scheduling cronjobs
Notable Features
- ▸Unix pipelines
- ▸Command substitution
- ▸Scripting with loops & conditionals
- ▸Environment variable management
- ▸Job control & process management
Origin & Creator
Created by Brian Fox at the Free Software Foundation in 1989 as a free replacement for the Bourne Shell (sh).
Industrial Note
Bash excels in environments requiring quick system automation, CI/CD pipelines, container orchestration scripts, server automation, cloud provisioning scripts, and Unix-level glue code that ties together native tools.