2009-12-10 38 views

回答

12

您可以使用 「read」:

$ cat ./test.sh 
#!/bin/sh 
echo -n "enter the value : " 
read my_var 

echo "The value is : $my_var" 

而且,執行該腳本:

$ sh ./test.sh 
enter the value : 145 
The value is : 145 
+4

Bash:「read」有一些有用的選項,例如-p指定提示: read -p'輸入值:'my_var 有關更多信息,請參閱「幫助閱讀」。 – 2009-12-10 18:02:58