2017-04-25 87 views
0

比方說,我需要一個bash shell腳本中的用戶輸入。例如:是否有可能在bash中部分自動填充輸入?

What is your name: | 

|是光標)

而不是一個空白項的空間,是可以自動填充輸入的用戶,那麼他或她可以繼續改變輸入如果需要並按回車?

What is your name: Mathew| 
What is your name: Mat| 
What is your name: Matthew| 

回答

3

是,使用read

read -e -p "What is your name: " -i "Mathew" RESULT 
echo $RESULT 

會給你:

Enter your name: Mathew 

,您還可以編輯或只需按下Enter鍵,$結果將持有的價值

相關問題