Test command recap
As we have seen in some of our previous examples, we used the shell built-in test to perform some checks on variables and files along with the conditional if...then so that we could make our script react to conditions: if the test is successful it returns 0, if it is not, 1, and these are the values that triggered our reactions so far.
We can use a couple of different notations to a test and we already saw them:
[expression]or
[[expression]]We already spoke about the differences between the two, but let us quickly recap them before proceeding:
- The single bracket implements the standard POSIX compliant
testcommand and it is available in all POSIX shells.[is actually a command whose argument is],and this prevents the single brackets from receiving further arguments.- Some Linux versions still have a
/bin/[command, but thebuilt-inversion has the precedence in execution.
- Some Linux versions still have a
- The double brackets is only available in Bash,
zsh, andkornshells. - The double brackets is a keyword...