Skip to content

Instantly share code, notes, and snippets.

@raghav4
Created October 9, 2019 20:39
Show Gist options
  • Select an option

  • Save raghav4/405650858f62c3f5d558e0532a67d9e0 to your computer and use it in GitHub Desktop.

Select an option

Save raghav4/405650858f62c3f5d558e0532a67d9e0 to your computer and use it in GitHub Desktop.
Introduction to Shell Scripting
#! /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