shell script If Statement ( If then , If then else, If elif else)

1 min read
Model 1
#!/usr/bin/bash
count=10 if [ $count -eq 10 ]
then
echo "Condition True"
fi
Model 2
#!/usr/bin/bash
count=10
if [ $count -ne 0 ]
then
echo "Condition True" fi
Model 3
#!/usr/bin/bash
count=10
if [ $count > 0 ]
then
echo "Condition True"
fi
Model 4
!/usr/bin/bash
word=abc
if [ $word == "abc" ]
then
echo "Condition True"
fi
Method 5
!/usr/bin/bash
word=abc
if [ $word == "ab" ]
then
echo "Condition True"
else
echo "Condition False"
fi
Method 6
word=a
if [ $word == "b" ]
then
echo "Condition b is True"
elif [ $word == "a" ]
then
echo "Condition a is True"
else
echo "condition is false"
fi
0
Subscribe to my newsletter
Read articles from Sundar blog directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
