An interactive command-line calculator built using Bash Shell Scripting. This project performs basic arithmetic operations directly from the Linux terminal and demonstrates fundamental shell scripting concepts.
Developed as part of a Linux Lab Project.
- ➕ Addition
- ➖ Subtraction
- ✖️ Multiplication
- ➗ Division
- 🔄 Menu-driven interface
- 🚪 Exit option with confirmation
⚠️ Handles invalid user input gracefully
- Bash Shell Scripting
- Linux Terminal
bc(Basic Calculator Utility)
Before running the script, ensure you have:
- Linux / Ubuntu Operating System
- Bash Shell
bcpackage installed
Install bc if required:
sudo apt install bcSave the source code as:
simple_calculator.sh
chmod +x simple_calculator.sh./simple_calculator.shSimple Calculator
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit
Enter your choice (1-5):
| Option | Operation |
|---|---|
| 1 | Addition |
| 2 | Subtraction |
| 3 | Multiplication |
| 4 | Division |
| 5 | Exit Program |
Enter your choice (1-5): 1
Enter two numbers: 10 20
10 + 20 = 30
Enter your choice (1-5): 2
Enter two numbers: 50 20
50 - 20 = 30
Enter your choice (1-5): 3
Enter two numbers: 6 7
6 * 7 = 42
Enter your choice (1-5): 4
Enter two numbers: 10 3
10 / 3 = 3.33
Enter your choice (1-5): 5
Are you sure you want to exit? (y/n): y
Goodbye!
This project helped in understanding:
- Shell Scripting Basics
- Conditional Statements (
if-else) - Loops (
while) - User Input Handling
- Functions in Bash
- Command-Line Utilities
- Menu-Driven Programming
- Updated project documentation.
This project was developed as part of the Linux Laboratory coursework to strengthen command-line programming and scripting skills.
Lavanya Agrawal
B.Tech Computer Science Engineering UPES, Dehradun
GitHub: https://github.com/lavanyaag23