Learning shell (b)

  1. Conditional branch: (conditional expression inside the brackets in space can not be omitted)
    IF [ 2 = 2 ]
     the then  
    echo  ' 2 = 2 ' ;
     the else 
    echo  ' ! 2 = 2 ' ;
     Fi 
    # above code no indentation and no errors, but should not be so used 
    # above is obviously employed as the carriage return command at the end, then if the above lines of code on one line, IF behind the conditional expression must be a semicolon, otherwise given example:
     IF [ 2 = 2 ] ;  the then  echo  ' 2 equal 2 ' ;  the else  echo  ' ! 2 = 2 ' ;  fi 
    # If the non-write must be written in one line, marked red semicolon, in fact, just keep good coding habits, the indentation on the indentation, wrap wrap, do not need to consider the above question

     

  2. read command reads from standard input line, and specify the value of each field input line to shell variables. His $ 0 and $ 1 this difference is that $ 0 is in the implementation of the file, along with the incoming parameters, if not incoming parameters, then there is no argument, while the read will prompt the user for input after running the script file to obtain a user input

Guess you like

Origin www.cnblogs.com/bneglect/p/11363098.html