shell编程——Shell读取用户输入
读取用户输入选择性输入,例如yes or no密码输入,不适合回显read命令读取用户输入,输入的内容放到变量里read nameecho "read name, name is $name"read ageecho "read age, age is $age"read命令的返回值,只有输入ctrl+d才会返回非0read nameecho $?read -p选项可提示用户输入啥内容read -
读取用户输入
选择性输入,例如yes or no
密码输入,不适合回显
read命令读取用户输入,输入的内容放到变量里
read name
echo "read name, name is $name"
read age
echo "read age, age is $age"
read命令的返回值,只有输入ctrl+d才会返回非0
read name
echo $?
read -p选项可提示用户输入啥内容
read -p "Please input your name: " name
echo "read name, name is $name"
read -p "Please input your age: " age
echo "read age, age is $age"
read -s选项输入密码
read -s -p "Please input your password: " mypwd
echo "read pwd, pwd is $mypwd"
更改nginx安装脚本,支持输入安装目录
read -p "Please input you installpath: " installpath
if [ -e "$installpath" ];then
echo "nginx is installed. exit script"
exit 1
fi
nginxdownloadurl="http://nginx.org/download/nginx-1.12.2.tar.gz"
yum -y install wget gcc pcre pcre-devel zlib zlib-devel
cd /usr/local/src/
wget "$nginxdownloadurl"
tar -zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure --prefix=$installpath && make && make install
更多推荐
所有评论(0)