Control Structures

if … then statement

if [ test_command ]
then

        commands

fi
if … then … else statement

if [ test_command ]
then

     commands

else

     commands

fi
if … then … elif … (else) statement

if [ test_command ]

then

     commands
elif [ test_command ]
then

     commands

elif [ test_command ]
then

     commands
.
.
.
else     (Optional)

     commands

fi
for … in statement

for loop_variable in argument_list
do

    commands

done
while test_condition_is_true
do

    commands

done
until test_condition_is_true
do

    commands

done
case statement

case $variable in

match_1)

        commands_to_execute_for_1

        ;;

match_2)

        commands_to_execute_for_2

       ;;

match_3)

        commands_to_execute_for_3

       ;;
.
.
.

 *)    (Optional - any other value)

       commands_to_execute_for_no_match

     ;;

esac

 

posted @ 2016-09-28 09:47  ordi  阅读(196)  评论(0)    收藏  举报