Control Structures

ifthen statement

if [ test_command ]
then

        commands

fi
ifthenelse statement

if [ test_command ]
then

     commands

else

     commands

fi
ifthenelif … (else) statement

if [ test_command ]

then

     commands
elif [ test_command ]
then

     commands

elif [ test_command ]
then

     commands
.
.
.
else     (Optional)

     commands

fi
forin 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  阅读(162)  评论(0编辑  收藏  举报