2
It’s an alias for test
. See man 1 test:
Name
test - check file types and compare values
Synopsis
test EXPRESSION
test
[ EXPRESSION ]
[ ]
[ OPTION
The test command is sometimes used together with if
to create a conditional block. It’s also useful on its own:
[ ! -d myDirectory ] && mkdir myDirectory
This would test whether a directory “myDirectory” does not exist and create it if that’s true.
Because it’s (also) for conditions, it must not print anything. Instead, it communicates via exit codes.
This command exists on virtually all GNU/Linux systems and many Unix variants.
See here for a more in-depth explanation.