If This, Then That: if and [[ ]]
if lets a script choose: the commands after then run only when a test passes, [[ ]] compares text with == and whole numbers with -lt and its friends, and if can also ask whether any command worked.
Updated
![Cheat sheet for the lesson If This, Then That: if and [[ ]]: if lets a script choose: the commands after then run only when a test passes, [[ ]] compares text with == and whole numbers with -lt and its friends, and if can also ask whether any command worked.](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/932f57258a594bf0a9d96a74a424ab90.webp)
- Category
- Bash
- Level
- Apprentice
- Tags
- exit-code, if-statement, linux, shell-script, test-command, unix