Skip to main content

Command Palette

Search for a command to run...

if Statements

Published
•1 min read•View as Markdown
O

Linux , Devops , c , c++ , python

#! /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