Bash scripting is a powerful way to automate tasks and perform various operations in a Linux environment. Here you will learn to create a simple Bash script that takes two numbers as input, adds them together, and displays the result. This serves as a basic introduction to scripting with Bash.
Script Creation:
Let's create a Bash script named add_numbers.sh
Script:
#!/bin/bash
# Simple script to add two numbers
# Ask the user for the first number
echo "Enter the first number:"
read num1
# Ask the user for the second number
echo "Enter the second number:"
read num2
# Calculate the sum
sum=$((num1 + num2))
# Display the result
echo "The sum of $num1 and $num2 is: $sum"
- echo: Prints a message on the screen.
- read: Gets input from the user and stores it in a variable.
- $((num1 + num2)): Performs arithmetic addition.
- $sum: Displays the value of the variable sum.

To use this script:
- Save it to a file, add_numbers.sh.
- Make it executable:
chmod +x add_numbers.sh- Run it:
./add_numbers.shOutput:
