系统命令_$REPLY
$REPLY : 当没有参数变量提供给read命令的时候,这个变量会作为默认变量提供给read命令
#!/bin/bash #reply.sh #REPLY是提供给'read'命令的默认变量.
echo echo -n "What is you favorite vegetable?" read
#当没有变量提供给'read'命令时,REPLY才保存最后一个'read'命令读入的值 echo "Your favorite vegetable is $REPLY"
echo "----------------"
echo
echo -n "What is you favorite fruit?" read fruit echo "Your favorite fruit is $fruit" echo "but..." #$REPLY还是保存着上一个命令的值,因为变量$fruit被传入到了这个新的"read"命令中 echo "Value of $REPLY is still $REPLY" echo exit 0
--------------运行结果-------------
sh reply.sh
What is you favorite vegetable?123 Your favorite vegetable is 123
What is you favorite fruit?apple Your favorite fruit is apple but... Value of $REPLY is still 123