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 test - Bash Tutorial
From the course: Learning Bash Scripting
Comparing values with test
- In scripts it's common to need to compare things and test values. Bash has a built-in called Test, which is also represented by single brackets. This built-in works in the same way as the test command which is part of the GNU coreutils, the set of tools that are available on many Linux distributions. Test is widely compatible across shells and it's worth taking a moment to look at the help for the test built-in. There are a variety of operations that Test can well, test. (key taps) We can do this with a command help test. There are a variety of operations that Test can well, test. Including checking to see whether a file exists, whether a file is a directory and many other things that can be useful for a script to know. We can use the test built in with a square bracket notation in a script. Or right here at the command line. I'll clear my screen and then let's ask Bash whether my home directory is a directory.…
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
-
-
-
-
-