Applying Conditions Statements in Sh Script ..๐Ÿ˜ฏ

Applying Conditions Statements in Sh Script ..๐Ÿ˜ฏ

ยท

2 min read

Here we can easily put condition in our daily life. Pick that and lets put conditions on todays script.

Prerequisites are only make a dir to make them separate from the others.

Step 1 : We are going to create a .sh file whatever we wanna name it but it should match the subject.

$ touch arejoeyfamous.sh 
or 
$ vim arejoeyfamous.sh

Step 2 : Now its time to put condition on joey's life through the script. All the script is saying that Joey wanna be a famous public figure although he's funny, handsome and he can act brilliant as well. So he bring his career on acting and to become a public figure he have to work hard and his skill percentage will show that how much he goes on this track . If it below 90% he is working hard , if it is over 90% then he became what he wants always. Can he be a public figure or not !! That's it. Let's write it...

#!/bin/bash
#
#
<< disclaimer

This Time to Poke 
and ask him 
How's He Doing 
In His Life !!

disclaimer



read -p "Enter the profession Joey wanna Join : " Proffession

read -p "Enter the Skill % again : " Skill

if [[ $Proffession == Acting ]];
   [[ $Skill -lt 90 ]];

then
        echo "Joey bring his career on Acting Field"


elif [[ $Skill -gt 90 ]];

then

        echo "Joey Became a Public Figure"

else

        echo "Joey Is Working Hard to Become a Public Figure"
fi

Step 3 : Make the executeable and giving the permissions to who can do what to the file with this command.

$ chmod 777 arejoeyfamous.sh
$ bash filename.sh 
or 
$ ./arejoeyfamous.sh

Step 4 : We will take action from user like that and according to conditions the percentage will tell us in which stage he is now. Just play with it.

Dont be panic on syntax errors like me, every small steps will lift you to the new heights. Here we can see Joey became a celebrity. Ccome out with a handshake with him and look further for next step.

Did you find this article valuable?

Support dailydoseindevops by becoming a sponsor. Any amount is appreciated!