2014-02-20 55 views
-2

我想讓我的腳本用戶交互。在運行應該出現在屏幕上,該腳本(./versionControl.sh)的第一件事就是用戶交互Shell腳本

Please enter the package name:: 

當用戶進入應該採取作爲輸入包名,做進一步的操作包名

我怎樣才能做到這一點?好心幫

+1

你試過什麼嗎? – 2014-02-20 21:00:31

+1

[我如何提示輸入Linux shell腳本?](http://stackoverflow.com/questions/226703/how-do-i-prompt-for-input-in-a-linux-shell -script) – lurker

回答

2

你想使用的BASH read命令,就像這樣:這裏

echo "Enter your name, followed by [ENTER]:" 
read name 
echo $name 

檢查的詳細信息:read user input

+1

'read -p「輸入你的名字,然後按[Enter]:」'就足夠了。 – lurker

+0

確實,濃縮總是更好,偉大的建議@mbratch – binaryatrocity

0

假設你的意思慶典,這些都是一些命令這會讓你滾動:

echo "this command, echo, will output words on a screen."; 

# This pound sign is a comment, and I can use it to tell you that the read 
# command below allows you to capture input 

read someVariable; 

echo "using the dollar sign i can tell you that you entered $someVariable";