if Statements
#! /bin/bash
#Integers comparison operators
#String comparison #{ { = , == , != } ..... [ "$a" = "$b" ] #{ {< , > , -z {for null string , #zero-length string } ..... [[ "$a" < "$b" ]]
count=10
if [ $count -eq 10 ]
then
echo "Number Equal to 10 "
fi
if (( $count >=9 ))
then
echo "Number greater than 10"
fi
word="abc"
if [ $word == "abc" ]
then
echo "Strings are equal "
fi
echo "Enter your string "
read word
if [ $word == "abc" ]
then
echo "Strings are equal "
else
echo "Strings are not equal"
fi
echo "Enter your word "
read word
if [ $word == "a" ]
then
echo "Word is a "
elif [[ $word = "b" ]]
then
echo "Word is b "
else
echo "None of this "
fi
Subscribe to my newsletter
Read articles from Omkar Venkatrao Punjaji directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Omkar Venkatrao Punjaji
Omkar Venkatrao Punjaji
Linux , Devops , c , c++ , python