Research V3 development
[unix-history] / man / man1 / if.1
CommitLineData
3cc4e5af
DR
1.pa 1
2.he 'IF (I)'3/15/72'IF (I)'
3.ti 0
4NAME if -- conditional command
5.sp
6.ti 0
7SYNOPSIS if\b\b__ expr command [ arg\e91\e8 ... ]
8.sp
9.ti 0
10DESCRIPTION if\b\b__
11evaluates the expression expr\b\b\b\b____, and if its value is true\b\b\b\b____,
12executes the given command\b\b\b\b\b\b\b_______ with the given arguments.
13
14The following primitives are used to construct
15the expr\b\b\b\b____:
16
17.in +9
18.ti -4
19-r\b\b__ file
20.br
21true if the file exists and is readable.
22
23.ti -4
24-w\b\b__ file
25.br
26true if the file exists and is writable
27
28.ti -4
29s1 =\b_ s2
30.br
31true if the strings s1\b\b__ and s2\b\b__ are equal.
32
33.ti -4
34s1 !=\b\b__ s2
35.br
36true if the strings s1\b\b__ and s2\b\b__ are not equal.
37
38.in -9
39These primaries may be combined with the
40following operators:
41
42.in +5
43!\b_
44.ti +4
45unary negation operator
46
47-a\b\b__
48.ti +4
49binary and\b\b\b___ operator
50
51-o\b\b__
52.ti +4
53binary or\b\b__ operator
54
55(\b_ expr )\b_
56.ti +4
57parentheses for grouping.
58
59.in -5
60-a\b\b__ has higher precedence than -o\b\b__.
61Notice that all the operators and flags are separate
62arguments to if\b\b__ and hence must be surrounded by spaces.
63.sp
64.ti 0
65FILES --
66.sp
67.ti 0
68SEE ALSO sh(I)
69.sp
70.ti 0
71DIAGNOSTICS "if error",
72if the expression has the wrong syntax;
73"command not found."
74.sp
75.ti 0
76BUGS --