O'Reilly logo

Mac OS X Tiger in a Nutshell by Jason McIntosh, Chuck Toporek, Chris Stone, Andy Lester

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

Name

if

Synopsis

                     
                        if
                      
                     test-cmds

Begin a conditional statement. The possible formats, shown here side by side, are:

    if test-cmds    if test-cmds      if test-cmds
       then            then             then
          cmds1          
                     cmds1             
                     cmds1
    fi                 else             elif test-cmds
                          cmds2            then
                    fi                        cmds2
                                              ...
                                        else
                                           cmdsn
                                      fi

Usually, the initial if and any elif lines execute one test or [ ] command (although any series of commands is permitted). When if succeeds (that is, the last of its test-cmds returns 0), cmds1 are performed; otherwise, each succeeding elif or else line is tried.

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