O'Reilly logo

Solaris™ 8 Advanced System Administrator's Guide, Third Edition by Janice Winsor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing for Conditions

When writing scripts, you frequently want to test for conditions. The simplest test is to determine whether a condition is true or false. If the expression is true, execute any subsequent commands (shown indented in Table 90); if not, continue with the script. Table 90 shows the syntax for conditional tests.

Table 90. Conditional Test Syntax
Bourne and Korn Shells C Shell
if command

then

  commands

elif command
										  commands

else

  commands

fi
if (cond) then

  commands

else if (cond) then

  commands

else

  commands

endif

if-then-else-elif

For the Bourne and Korn shells, use the if-then-else-elif-fi syntax to test for conditions. You can follow the if statement with the test command and its argument(s) to test for conditions. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required