返回顶部

编写脚本checkint.Sh,判断用户输入的参数是否为正整数

  1.  

     

    [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

posted @ 2020-08-30 23:00  九尾cat  阅读(356)  评论(0编辑  收藏  举报