shell 交互输入

阅读更多
#!/bin/bash
echo -e "MySQL Server has already installed"
echo -e "Enter Y skip mysqld installed"
echo -e "Enter N will exit installing"
read -p "Do you want to skip? Y/N: " skip
if [ $skip == 'Y' ];then
    echo -e "skip"
elif [ $skip == 'N' ]; then
    echo -e "not skip"
else
    echo -e "unknown args"
fi

   1. 初次使用 echo 命令,有些人不知道 -e 参数,结果输出的字符串中存在\n, \t等转义字符不能正常输出;

   2. read -p "desc" variable,注意 variable 变量与描述内容 desc 之间留空格;

你可能感兴趣的:(shell 交互输入)