用户交互式,Shell脚本

时间:2014-02-20 20:58:46

标签: shell

我想让我的脚本用户互动。在运行脚本(./versionControl.sh)时,应该出现在屏幕上的第一件事是

Please enter the package name::

当用户输入包名称时,它应该将该包名称作为输入并执行进一步的操作

我怎样才能做到这一点?请帮助

2 个答案:

答案 0 :(得分:2)

您将要使用BASH read命令,如下所示:

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

点击此处了解详情:read user input

答案 1 :(得分:0)

假设您的意思是 bash ,这些命令会让您滚动:

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";