[Linux_Shell scripting study notes Third, branch and loop structures]

 

 

  if the actual production work statement is the most important and most commonly used statement, therefore, we must firmly grasp

  

  if conditions grammar

    1. Single branch

        if [condition]

          then 

            instruction

          be

 

     or

        if [Condition]; then 

          instruction

        be

                   

         

        And previously studied the expression can be converted to each other

        

        

        Two-branch structure

          grammar:

          if [condition]

            then  

                Instruction Set 1

          else  

              Instruction Set 2

                   be

          Tip: Before text file conditional expression [-f "$ file1"] && echo 1 || echo 0

          Is equivalent to the bifurcation if [-f "$ file1"]; then echo 1; else echo 0; fi

 

          

 

          Multi-branch sentence structure

          

 

          

 

 

 

 

 

 

 

 

 

 

 

 

 

 

          

Guess you like

Origin www.cnblogs.com/kangxinxin/p/11241917.html