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

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