Home OS X
OS X Syntax

if

Conditionally perform a command.

SYNTAX
       if (expr) command
	       If expr (an expression, as described under Expressions)	evalu-
	       ates  true, then command is executed.  Variable substitution on
	       command happens early, at the same time it does for the rest of
	       the  if	command.   command  must  be  a simple command, not an
	       alias, a pipeline, a command list or  a	parenthesized  command
	       list,  but  it  may  have  arguments.  Input/output redirection
	       occurs even if expr is false and command is thus not  executed;
	       this is a bug.

       if (expr) then
       ...
       else if (expr2) then
       ...
       else
       ...
       endif   If  the	specified  expr is true then the commands to the first
	       else are executed; otherwise if expr2 is true then the commands
	       to  the	second	else are executed, etc.	 Any number of else-if
	       pairs are possible; only one endif is needed.  The else part is
	       likewise	 optional.   (The  words else and endif must appear at
	       the beginning of input lines; the if must appear alone  on  its
	       input line or after an else.)

`if' is a tcsh shell command.

"Then you admit confirming not denying you ever said that?"
"NO! ... I mean Yes! WHAT?"
I'll put `maybe.' - Bloom County

Related commands:

awk - Find and Replace text within file(s)
eval - Evaluate several commands/arguments
expr - Evaluate expressions
foreach - Expand words, and execute commands
repeat - execute a command multiple times
switch - Conditionally perform a command
while - Execute commands

Equivalent BASH command:

if
- Conditionally perform a command



Back to the Top

Simon Sheppard
SS64.com