shell script day05- interactive input and for statement

First, the interactive input (please try to avoid using)

  read python with input () function input

  The read command may define a plurality of variable values ​​at the same time; and the contents of the input space separator default, the value of the input variable value corresponding to a; if too many variables default values, the last value will be given a final variable.

  If the default value is too small, the excess will become variable control

  How 1.read input:

    echo "Please enter a directory."

       (We need to cancel echo -n newline)

    echo "Please enter a directory"; read variables

    Please enter a directory: \ etc

  Common parameters:

  • -p read -p "Please enter a directory" variable
  • -t read -t 5 "Please enter a directory" // define the variable timeout

  Script Default:

    

Two, for the statement cycle

  for scenarios statement: When a loop is executed and the function needs to perform different objects (object must be the same data)

  format for statement:  

for variables in A 
    loop 
done

  List Builder way:

  1. Direct given a list of strings
  2. List of integers
  3. Returns a list of command
  4. glob mechanisms - file name wildcard mechanism
  5. Variable references - mass participation  

       supplement  

          

 

Guess you like

Origin www.cnblogs.com/ljx1/p/11365434.html
Recommended