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 - 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
-
-
-
-
Understanding Bash script syntax5m 18s
-
(Locked)
Choosing a text editor for Bash scripting1m 33s
-
(Locked)
Displaying text with "echo"4m 26s
-
(Locked)
Working with variables5m 21s
-
(Locked)
Working with numbers8m 44s
-
(Locked)
Comparing values with test4m 59s
-
(Locked)
Comparing values with extended test3m 34s
-
(Locked)
Formatting and styling text output8m 13s
-
(Locked)
Formatting output with printf5m 6s
-
(Locked)
Working with arrays4m 25s
-
(Locked)
Challenge: Make a script that generates a system report1m 1s
-
(Locked)
Solution: Make a script that generates a system report1m 26s
-
-
-
-
-