builtin

Bash test builtin

Evaluates an expression; 0 means true, 1 false, and invalid input can give a higher status. Each operand and operator is a separate argument.

Formal Syntax & Structure

bash syntaxbash
test expression

Parameters & Attributes

NameTypeDescription
expressionargumentsString, integer or file predicate.

Return Value

exit status

Evaluates an expression; 0 means true, 1 false, and invalid input can give a higher status. Each operand and operator is a separate argument.

Working Example

Example Snippetbash
label=''if test -z "$label"; then printf '%s\n' empty; filabel='daily report'if [ -n "$label" ]; then printf '%s\n' present; fi
Bash Reference