Skip to content

Instantly share code, notes, and snippets.

@dharshan
Last active May 22, 2018 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dharshan/77e5a63b4e62a2f4add6fe914e03d9f8 to your computer and use it in GitHub Desktop.
Save dharshan/77e5a63b4e62a2f4add6fe914e03d9f8 to your computer and use it in GitHub Desktop.
shell script to add two numbers
#!/bin/bash
# Above line to specify which shell to be used to execute the program
echo "Enter first Number" # echo used to print the message to screen
read first_number # read and store the input from terminal
echo "enter second Number"
read second_number
sum=`expr $first_number + $second_number` # things insed the backtick ` are evaluate or executed
echo "$first_number + $second_number = $sum" # $ to specify arguments
# give execution permission to file before running the program like bellow
# chmod +x add1.sh
# run the program by ./add1.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment