Research V3 development
[unix-history] / man / man1 / if.1
.pa 1
.he 'IF (I)'3/15/72'IF (I)'
.ti 0
NAME if -- conditional command
.sp
.ti 0
SYNOPSIS if\b\b__ expr command [ arg\e91\e8 ... ]
.sp
.ti 0
DESCRIPTION if\b\b__
evaluates the expression expr\b\b\b\b____, and if its value is true\b\b\b\b____,
executes the given command\b\b\b\b\b\b\b_______ with the given arguments.
The following primitives are used to construct
the expr\b\b\b\b____:
.in +9
.ti -4
-r\b\b__ file
.br
true if the file exists and is readable.
.ti -4
-w\b\b__ file
.br
true if the file exists and is writable
.ti -4
s1 =\b_ s2
.br
true if the strings s1\b\b__ and s2\b\b__ are equal.
.ti -4
s1 !=\b\b__ s2
.br
true if the strings s1\b\b__ and s2\b\b__ are not equal.
.in -9
These primaries may be combined with the
following operators:
.in +5
!\b_
.ti +4
unary negation operator
-a\b\b__
.ti +4
binary and\b\b\b___ operator
-o\b\b__
.ti +4
binary or\b\b__ operator
(\b_ expr )\b_
.ti +4
parentheses for grouping.
.in -5
-a\b\b__ has higher precedence than -o\b\b__.
Notice that all the operators and flags are separate
arguments to if\b\b__ and hence must be surrounded by spaces.
.sp
.ti 0
FILES --
.sp
.ti 0
SEE ALSO sh(I)
.sp
.ti 0
DIAGNOSTICS "if error",
if the expression has the wrong syntax;
"command not found."
.sp
.ti 0
BUGS --