How do i use the test command in bash and bash shell scripts?
-
See all the options for test in the Man page for test.
The basic syntax is:
test expressione.g: The expression part is
-d /var/log
test -d /var/logIt can also be written as:
[ -d /var/log ]Some common options for string tests are, see if a string has a value,
-n
and see if a string is empty (zero value) with-z
The test command can also do tests with integers, check file types, see if a file exists. See the man page for more.
© Lightnetics 2024