2014-02-20 107 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";