千家信息网

judge input type

发表于:2025-12-01 作者:千家信息网编辑
千家信息网最后更新 2025年12月01日,#! /bin/bashwhile true;doread -p "please input:" aexpr $a + 1 &> /dev/nullif [ $? -eq 0 ] ;thenecho
千家信息网最后更新 2025年12月01日judge input type

#! /bin/bash
while true;do
read -p "please input:" a
expr $a + 1 &> /dev/null
if [ $? -eq 0 ] ;then
echo "input is int."
else
echo "input is char."
fi
if [ $a == 'q' ];then
break
fi
done

0