Bash Scripting else if statement
In Linux, all tasks from execution of services to loading and unloading of
modules are carried out by programs and all programs need to be executed. You
use the commands to access all the basic features of kernel. Shell scripting
is a way to automate such tasks, and bash is one of the language, that has
capabilities enough to be called as scripting as well as a language that can
be used for programming on the POSIX platform, for small tasks. Bash Scripting else if statement
Using else if statement
The use of else if condition is little different in bash than other programming language. ‘elif’ is used to define else if condition in bash. Create a file named, ‘elseif_example.sh’ and add the following script to check how else if is defined in bash script.
#!/bin/bash
echo "Enter your lucky number"
read n
if [ $n -eq 101 ];
then
echo "you got the first prize"
elif [ $n -eq 510 ];
then
echo "You got 2nd prize"
elif [ $n -eq 999 ];
then
echo "You got 3rd prize"
else
echo "Sorry, try for the next time"
fi
Run the file with bash command.
I hope you liked this post, then you should not forget to share this post at
all.
Thank you so much :-)
Disclaimer
This was written for educational purpose and pentest only.
The
author will not be responsible for any damage ..!
The author of this tool
is not responsible for any misuse of the information.
You will not misuse
the information to gain unauthorized access.
This information shall only
be used to expand knowledge and not for causing malicious or damaging
attacks. Performing any hacks without written permission is illegal ..!
All tutorials and videos have been made using our own routers, servers, websites and other resources, they do not contain any illegal activity. We do not promote, encourage, support or excite any illegal activity or hacking without written permission in general. We want to raise security awareness and inform our readers on how to prevent themselves from being a victim of hackers. If you plan to use the information for illegal purposes, please leave this website now. We cannot be held responsible for any misuse of the given information.
- Hacking Truth by Kumar Atul Jaiswal