编写脚本checkint.Sh,判断用户输入的参数是否为正整数
-
[root@centos8 ~]#cat checks.sh
#!/bin/bash
#********************************************************************
#Author: wei
#QQ:
#Date:
#FileName: chechkint.sh
#URL:
#Description: The test script
#Copyright (C): 2020 All rights reserved
#********************************************************************
read -p "请输入数字:" i
DIGIT=$((i%1))
if [ $i -lt 1 ] ; then
echo "输入$i不是正整数"
elif [ ! $DIGIT -gt 0 ] ; then
echo "输入$i是正整数"
else
echo "输入$i不是正整数"
fi