test

Evaluate condition as true or false

Usage: test condition

or

[ condition ]

SEE ALSO

For more information, see page 766

File tests:

-f name means is name a regular file?

-d name means is name a directory?

-r name means is name readable?

-w name means is name writable?

-x name means is name executable?

-c name means is name a character device file?

-b name means is name a block device file?

-s name means is name a file with size is greater than zero?

-h or -L name means is name a symbolic link?

String tests:

"string" means is string not empty?

-z string means is string empty (zero size)?

s1 = s2 means are the two strings the same?

s1 != s2 means are the ...

Get Practical UNIX 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.