Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ if(I) — UNIX 6th Edition

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sh (I)

find (I)

IF(I)  −  PWB/UNIX 5/2/74

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 filetrue if the file exists and is readable. 

−w filetrue if the file exists and is writable. 

s1 = s2true if the strings s1 and s2 are equal. 

s1 != s2true if the strings s1 and s2 are not equal. 

{ command }The bracketed command is executed to obtain the exit status.  Status zero is considered true.  The command must not be another if. 

These primaries may be combined with the following operators:

!unary negation operator

−abinary and operator

−obinary 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

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026