天天看點

内部變量REPLY

用處一:在read語句中:

[root@server100 shell]# read     #在不使用參數的時候,read從标準輸入讀取的值,将會存儲$REPLY内部變量中
mah
[root@server100 shell]# echo $REPLY
mah
[root@server100 shell]# read var
MAH
[root@server100 shell]# echo $var
MAH      
#!/bin/bash
echo "Pls choose your professional:"
select var in "worker" "doctor" "teacher"
do
        echo "the \$REPLY is $REPLY"
        echo "your professional is $var"
        break
done

[root@server100 shell]# ./select1.sh 
Pls choose your professional:
1) worker
2) doctor
3) teacher
#? 1
the $REPLY is 1
your professional is worker