We can use if statements in scripting, in order to test a condition. The basic syntax of an if statement is as follows:
if [some condition]; then execute somethingfiorif [[some condition]]; then execute somethingfi
We can create a simple if script, using the preceding code as guidance. Sometimes, we may need to use double square brackets, which offer enhancements over the older, single-bracket style. Let's create a script named myif.sh, using vi or nano, as follows:
[philip@localhost Documents]$ vi myif.sh[philip@localhost Documents]$ cat myif.sh#!/bin/bashecho "Welcome to our if statement script"if [[ $1 == 4 ]]; then echo "You're very smart"fiecho "See you soon!"[philip@localhost Documents]$ chmod +x ...