Use Conditional Statements in Bash

Share this video with your friends

Send Tweet

Knowing how conditionals work in bash open up a world of scripting possibilities. We’ll learn the basic syntax, including if, else, and elif. Then we'll look at a few of the "primary" operators you can leverage in a conditional statement such as = for string equality, -eq for numeric equality, and -e to check if a file exists. After that, we'll use conditional statements to create a function that asserts that the HTTP status of a given URL is between 200 and 299.

Daniel Ram
Daniel Ram
~ 6 years ago

This may help others: https://stackoverflow.com/questions/18928260/if-command-with-user-input-osx-terminal