Techno World Inc - The Best Technical Encyclopedia Online!

THE TECHNO CLUB [ TECHNOWORLDINC.COM ] => Shell Script => Topic started by: Mark David on March 16, 2007, 01:42:24 PM



Title: csh C shell scripts: if statement syntax
Post by: Mark David on March 16, 2007, 01:42:24 PM
csh C shell scripts: if statement syntax

Conditional expressions give programs life. The ability to branch makes shell scripts powerful. This recipe shows the basic if then else structure for csh, the C shell.

Basic if statement syntax:

Code:
if (condition) then 
    commands
endif

The addition of one or more else keywords offers additional flexibility:

Code:
if (condition) then 
    commands
else if (other condition) then
    commands
else
    commands
endif