From the course: Learning Bash Scripting

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Comparing values with extended test

Comparing values with extended test - Bash Tutorial

From the course: Learning Bash Scripting

Comparing values with extended test

- In addition to the single bracket test notation, Bash gives us the double bracket notation called extended test. As with test, it's important to keep spaces between the sets of brackets and the expression we want to evaluate. Here in the terminal, I'll write an extended test to check whether four is less than three. Turns out it's not. Extended test gives us the same operations as test and adds a few other helpful features. With extended test, we can use more than one expression within a test to create a little bit more complex logic. For example, I can ask whether my home directory is a directory and whether the Bash binary exists. That set of statements is true. I could also ask if my home directory is a directory and whether there's a file called MASH in the bin directory. It remains true that my home directory is a directory but it's not true that there's a file called MASH in the bin directory, so the result is false.…

Contents