Shell read command Detailed

The official explanation : receive keyboard input or other file descriptors. receiving an input read command standard input (keyboard), or other input file descriptors. After obtaining input, read command data into a standard variable.
read command format is as follows:
#read [Options] [variable name]

Options:
-p : "message": read while waiting for input and output message;
-t : Number of seconds: read command has been waiting for user input, you can use this option to specify the wait time;
-n : Number of characters: read command receive only the number of characters specified will be executed;
-s : hidden data input for the input of confidential information;
variable names can be customized. If you do not specify a variable name, it will default to save input variable REPLY in;
If only a variable name, the entire input line assigned to the variable;
if provided more than one variable name, enter the word line is divided into several , one after imparting the variables, and the last variable on the command line to get all remaining characters;

For example Experiment

Edit the following script
Here Insert Picture Description
to remove the Chinese annotation to change the script contents:
! # / Bin / bash
the Read -t 30 -p "Please the INPUT your name:" name
echo "$ name the Name IS"
the Read -s -t 30 -p "Please the Enter your Age: "Age
echo -e" n-"
echo" IS $ Age Age "
Read 30 -n. 1 -t -p" Please your Gender SELECT [M / F.]: "Gender
echo -e" \ n-"
echo" Sex IS $ gender "

The implementation of the above script editor, we will get the following process.
Here Insert Picture Description
Note the following link switched segment description, personal notes after comprehension tests.
http://c.biancheng.net/view/969.html

Guess you like

Origin blog.csdn.net/tang3827738w/article/details/92215095