#!/bin/bash STR='GNU/Linux is an operating system' SUB='Linux' if [[ "$STR" == *"$SUB"* ]]; then echo "It's there." fi
Here is what the above code is Doing:
1. The first line is a shebang. It tells the shell what program to use to interpret the script.
2. The second line is a comment. It’s ignored by the shell.
3. The third line is a variable assignment. It assigns the string ‘GNU/Linux is an operating system’ to the variable STR.
4. The fourth line is another variable assignment. It assigns the string ‘Linux’ to the variable SUB.
5. The fifth line is a conditional statement. It checks if the string in the variable STR contains the string in the variable SUB.
6. The sixth line is a command. It prints the string ‘It’s there.’ to the terminal.
7. The seventh line is the end of the conditional statement.
8. The eighth line is the end of the script.