更新时间:2023-12-02 23:35:40
read
可以让您等到用户按下Enter键.它带有一个可选参数,该参数是变量的名称,它将在其中保存用户输入(包括所有换行符).
read
by default lets you wait until the user presses enter. It takes an optional parameter which is the name of a variable in which it'll save the user input (everything up to the newline).
eivanec@sisifo ~ $ read test
hello
eivanec@sisifo ~ $ echo $test
hello
您还可以通过-d
开关指定其他字符(而不是换行符)来等待.
You can also specify a different character to wait for (instead of newline) with the -d
switch.