用shell脚本语言,从键盘中读入一个字符串,判断输入的字符串是否同时包含数字和字母,
如果是,输出“yes”/
如果不是,输出“no”/
问题如上:
就是用read输入
如果是5s5s47s这种,就是 yes
如果是 uuuusss 或者 8888 999 就是 no
read -p "请输入一个字符串" str
if echo "$str"|grep "[a-zA-Z]" >/dev/null &&echo "$str"|grep "[0-9]" >/dev/null
then
echo "yes"
else
echo "no"
fi
if echo "$str"|grep "[a-zA-Z]" >/dev/null &&echo "$str"|grep "[0-9]" >/dev/null
then
echo "yes"
else
echo "no"
fi
温馨提示:答案为网友推荐,仅供参考