Created
October 9, 2019 20:39
-
-
Save raghav4/405650858f62c3f5d558e0532a67d9e0 to your computer and use it in GitHub Desktop.
Introduction to Shell Scripting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| # ECHO COMMAND | |
| echo Hello World! | |
| ## Variables | |
| # Convetion - Upper Case | |
| NAME="RAGHAV" | |
| echo "My Name is $NAME" | |
| # In variables in bash you don't have to give spaces | |
| # You can use ${} too. | |
| # User Input | |
| read -p "Enter your age : " AGE | |
| echo "So your Age is $AGE" | |
| # If Statement | |
| if [ "$NAME" == "RAGHAV" ] # Spaces here. | |
| then | |
| echo "Your Name is Raghav" | |
| elif [ "$NAME" == "Sharma" ] | |
| then | |
| echo "Your Name is $NAME ! I see.." | |
| else | |
| echo "Oops your Name is not Raghav!" | |
| fi | |
| # Comparison | |
| read -p "Enter first Number " NUM1 | |
| read -p "Enter second Number " NUM2 | |
| if [ "$NUM1" -eq "$NUM2" ] | |
| then | |
| echo "Both are equal!" | |
| elif [ "$NUM1" -gt "$NUM2" ] | |
| then | |
| echo "$NUM1 is greater!" | |
| else | |
| echo "Definetly $NUM2 is Greater!" | |
| fi | |
| # FILE CONDITIONS | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment