3/15/72                                                    IF (I)





NAME            if --  conditional command



SYNOPSIS        if expr command [ arg  ... ]
                                     1


DESCRIPTION     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



                     -c file

                         true if the file either exists and is

                         writable, or does not exist and is cre-

                         atable.



                     s1 = s2

                         true if the strings s1 and s2 are equal.



                     s1 != s2

                         true if the strings s1 and s2 are not

                         equal.



                These primaries may be combined with the follow-

                ing operators:



                     !

                         unary negation operator



                     -a

                         binary and operator



                     -o

                         binary or operator



                     ( expr )

                         parentheses for grouping.



                -a has higher precedence than -o.  Notice that

                all the operators and flags are separate argu-

                ments to if and hence must be surrounded by

                spaces.



FILES           --



SEE ALSO        sh(I)



DIAGNOSTICS     "if error", if the expression has the wrong syn-

                tax; "command not found."



BUGS            "-c" always indicates the file is creatable, even

                if it isn't.



OWNER           dmr