test

Evaluates an expression

test expression

[ expression ]

The test utility evaluates an expression and returns a condition code indicating that the expression is either true (0) or false (not 0). You can use brackets ([]) around the expression instead of using the word test (second format).

Arguments

The expression contains one or more criteria (see the following list) that test evaluates. A -a separating two criteria is a Boolean AND operator: Both criteria must be true for test to return a condition code of true. A -o is a Boolean OR operator. When -o separates two criteria, one or the other (or both) of the criteria must be true in order for test to return a condition code of true.

You can negate any criterion by preceding it with an exclamation ...

Get A Practical Guide to Red Hat® Linux® 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.