#!/bin/bash
#提示输入
read -p "请输入: " input
# 判断输入的是否是数字
if [[ $input =~ ^[0-9]+$ ]]; then
echo "$input 是数字"
else
echo "$input 不是数字"
fi
2.3作业 编写一个shell脚本判断用户输入的是否是数字
于 2024-02-03 21:01:07 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)
#!/bin/bash
#提示输入
read -p "请输入: " input
# 判断输入的是否是数字
if [[ $input =~ ^[0-9]+$ ]]; then
echo "$input 是数字"
else
echo "$input 不是数字"
fi