IF(I) - History


if - conditional command

if expr command [ arg ... ]

If evaluates the expression expr, and if its value is true, executes the given command with the given arguments.

The following primitives are used to construct the expr:

-r file
true if the file exists and is readable.
-w file
true if the file exists and is writable.
s1 = s2
true if the strings s1 and s2 are equal.
s1 != s2
true if the strings s1 and s2 are not equal.
{ command }
The bracketed command is executed to obtain the exit status. Status zero is considered true. The command must not be another if.

These primaries may be combined with the following operators:

unary negation operator
binary and operator
binary or operator
( expr )
parentheses for grouping.

-a has higher precedence than -o. Notice that all the operators and flags are separate arguments to if and hence must be surrounded by spaces. Notice also that parentheses are meaningful to the Shell and must be escaped.

sh(I), find(I)


UNIX® is a registered trademark of The Open Group.

Copyright © 2003-2019 .
All rights reserved. Contact