Research V4 development
[unix-history] / man / man1 / if.1
CommitLineData
41ec3b2b
DR
1.th IF I 3/15/72
2.sh NAME
3if \*- conditional command
4.sh SYNOPSIS
5.bd if
6expr command [ arg ... ]
7.sh DESCRIPTION
8.it If
9evaluates the expression
10.it expr,
11and if its value is
12true,
13executes the given
14.it command
15with the given arguments.
16.s3
17The following primitives are used to construct
18the
19.it expr:
20.s3
21.lp +10 10
22\fB\*-r\fR|file true if the file exists and is readable.
23.s3
24.lp +10 10
25\fB\*-w|\fRfile true if the file exists and is writable
26.s3
27.lp +10 10
28s1|\fB=|\fRs2 true
29if the strings
30.it s1
31and
32.it s2
33are equal.
34.s3
35.lp +10 10
36s1|\fB!=|\fRs2 true
37if the strings
38.it s1
39and
40.it s2
41are not equal.
42.s3
43.i0
44These primaries may be combined with the
45following operators:
46.s3
47.lp +10 10
48\fB!\fR unary negation operator
49.s3
50.lp +10 10
51\fB\*-a\fR binary
52.it and
53operator
54.s3
55.lp +10 10
56\fB\*-o\fR binary
57.it or
58operator
59.s3
60.lp +10 10
61\fB(|\fRexpr\fB|)\fR parentheses for grouping.
62.s3
63.i0
64.bd \*-a
65has higher precedence than
66.bd \*-o.
67Notice that all the operators and flags are separate
68arguments to
69.it if
70and hence must be surrounded by spaces.
71Notice also that parentheses are meaningful
72to the Shell and must be escaped.
73.sh "SEE ALSO"
74sh(I)
75.sh BUGS