Simple If/else Linux Shell Bash Script Example
👤 By Tubbi | 📆
Simple Linux Bash Shell Script
The following is an example script you can run on your Linux machine. The script prompts the user for an input, depending on the entered information, the script uses and if/else statement to determine which message to show.
!#/bin/bash
echo "Enter the domain name for this website?"
read website
echo "${website} Is cool!"
if [ $website == 'webune.com' ]
then
echo "You entered the correct answer"
else
echo "Incorrect, the correct answer is webune.com - Try again"
fi
After you have created this script, be sure to setup the correct permissions with the following commands:
$ chmod +x SCRIPTNAME
$ chmod 755 SCRIPTNAME
I hope that helps