home | help
IF(I)			    UNIX Programmer's Manual			   IF(I)

NAME
     if -  conditional command

SYNOPSIS
     if expr command [ arg ... ]

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.

     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  sta-
		  tus.	 Status zero is considered true.  The command must not
		  be another if.

     These primaries may be combined with the following 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  arguments  to  if  and  hence must be surrounded by
     spaces.  Notice also that parentheses are meaningful  to  the  Shell  and
     must be escaped.

SEE ALSO
     sh (I), find (I)

BUGS

Unix 6th Edition		     5/2/74				   IF(I)

home | help