Using the test shell builtin
It is probably time for us to pull over to the side of the scripting highway and look a little more at this command test
. This is both a shell builtin and a file executable in its own right. Of course, we will have to hit the built-in command first, unless we specify the full path to the file.
When the test command is run without any expressions to evaluate, then the test will return false. So, if we run the test as shown in the following command:
$ test
The exit status will be 1
, even though no error output is shown. The test
command will always return either True
or False
or 0
or 1
, respectively. The basic syntax of test
is:
test EXPRESSION
Or, we can inverse the test
command with:
test ! EXPRESSION
If we need to include ...
Get Mastering Linux Shell Scripting now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.