本博文介绍一下shell脚本中常用的条件和循环语句:

条件语句:

wKiom1m8ytPDGg7MAAB1t9_5n8Q866.png-wh_50

wKioL1m8yqbwwagtAABjimNDPgg179.png-wh_50


循环语句:

                 

wKiom1m85Ujh_CliAADW8iTjaj0281.png

wKioL1m85RuStYTHAAEP3Y0uARc766.png


示例:

  1. if语句:

                        eg1.

wKiom1m84nKBxVPFAAApB8IAI0o408.png

                        eg2.

wKioL1m84IXTlyA4AABuZdzfFnM224.png

    2.case语句:

          简单的case语句:

wKiom1m8zeCDE9ssAAA0uKo7qnY589.png-wh_50

            配合循环的case语句:

wKioL1m8zk7DIGchAABT9pp5fTA968.png-wh_50

    3.for语句:

                简单的for语句:eg1.

wKioL1m80mrg_AQxAAAr5_LcgQc167.png-wh_50

                        eg2.

wKiom1m84IGCmubEAAAcrbV1GpI163.png

                和case搭配的for语句:eg3.

wKiom1m81Svhe1YkAABqf-mQMoM817.png-wh_50

    4.while语句:

                            eg1.

wKioL1m81IPSpOOFAAAoS8DZm5g257.png-wh_50

                        eg2.

wKiom1m81GXDbaGoAAAyQ9C-NFM151.png-wh_50

     5.util语句:

wKiom1m83eWiQ4dGAAApJneF29U234.png-wh_50

     6.select语句:

wKiom1m836Tgd8ZfAABNgq0qP8A211.png