echo " Please enter your Name:"
read key
運(yùn)行后:
Please enter your Name:
my name
光標(biāo)在第二行上,如何停留咱"Please enter your Name:" 后!
在echo " Please enter your Name:"后加c
echo " Please enter your Name:c"
echo -n " Please enter your Name:"
根據(jù)shell不同,有不同的情況,最簡(jiǎn)單,最有效的辦法是 man echo
即然是精貼,就再給它加點(diǎn)料--雖然關(guān)聯(lián)系并不太大!
以下內(nèi)容轉(zhuǎn)自<永遠(yuǎn)的unix>,部份備注信息由本人增加。已在sco504下測(cè)試過。
#shell下輸入字元的例子
echo "Enter a character:"
stty raw #設(shè)為輸入字元方式,有的系統(tǒng)可用stty cbreak
stty -echo #設(shè)為不回顯方式
readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null` #塊大小為1byte,塊數(shù)1
stty -raw #取消字元輸入方式
stty echo #恢復(fù)回顯方式
echo "The key is:$readchar"
聯(lián)系客服