[

Official Description

Begins a comparison.

Syntax

[ expression ]

Options

-a can be used as a logical and operator in compound tests.

-o can be used as a logical or operator in compound tests.

Oddities

It has pretty much been replaced by the [[ ]] command.

It's similar to the test command.

Example

$ [ -x buzz ]
$ echo $?
0                            # buzz is executable
$
$ [ -x core ]
$ echo $?
1                            # core is not executable
$

Get Korn Shell Programming by Example 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.