0
- #/bin/bash
- read -p "输入" n
- m=`echo $n|sed 's/[0-9]//g' |sed 's/[-0-9]//g'`
- if [ -z $m ];then
- echo "数字"
- else
- echo "字符"
- fi
0
#!/bin/bash
read -p "please input a number :" n
m=`echo $n | sed 's/[0-9]//g'`
j=`echo $n | sed 's/[a-zA-Z]//g'`
f=`echo $n | sed 's/[0-9a-zA-Z]//g'`
if [ -z $f ];then
if [ -z $m ];then
echo "your input is 数字"
elif [ -z $j ];then
echo "your input is 字母"
else
echo "your input is 数字+字母"
fi
else
echo "your input is 特殊字符."
fi
read -p "please input a number :" n
m=`echo $n | sed 's/[0-9]//g'`
j=`echo $n | sed 's/[a-zA-Z]//g'`
f=`echo $n | sed 's/[0-9a-zA-Z]//g'`
if [ -z $f ];then
if [ -z $m ];then
echo "your input is 数字"
elif [ -z $j ];then
echo "your input is 字母"
else
echo "your input is 数字+字母"
fi
else
echo "your input is 特殊字符."
fi
0
- #!/bin/bash
- read -p "please input a number :" n
- m=`echo $n | sed 's/[0-9]//g'`
- j=`echo $n | sed 's/[a-zA-Z]//g'`
- f=`echo $n | sed 's/[0-9a-zA-Z]//g'`
- if [ -z $f ];then
- if [ -z $m ];then
- echo "your input is 数字"
- elif [ -z $j ];then
- echo "your input is 字母"
- else
- echo "your input is 数字+字母"
- fi
- else
- echo "your input is 特殊字符."
- fi
编辑回复