If structures to execute code based on a condition

Now, you can use the if statement to test a condition. if command
The general syntax is as follows:

if condition
then
command1
command2
...
commandN
fi

OR

if test var == value
then
command1
command2
...
commandN
fi

OR

if test -f /file/exists
then
command1
command2
...
commandN
fi

OR

if [ condition ]
then
command1
command2
....
..
fi

If given condition is true than the command1, command2..commandN are executed. Otherwise script continues directly to the next statement following the if structure. Open a text editor and create the script called verify.sh:

The if structure is pretty straightforward. The read command will read the password and store it to variable called pass. If $pass (i.e. password) is equal to "jerry", then "Password verified." is displayed. However, if it is not equal to "jerry", the script does not print any message and script will go to the next statement.
Here is another example (number.sh):