码迷,mamicode.com
首页 > 其他好文 > 详细

compare two digital

时间:2018-02-28 11:19:41      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:linux bash

#! /bin/bash
read -p "please input two numbers:" a b
if [ -z "$a" ] || [ -z "$b" ];then
echo " please input digital."
exit 2
fi
expr $a + 1 &> /dev/null
a1=echo $?
expr $b + 1 &> /dev/null
b1=echo $?
if [ "$a1" -ne 0 ] || [ "$b1" -ne 0 ];then
echo "you input is not digital."
exit 2
fi

if [ $a -gt $b ];then
echo "$a is bigger than $b."
elif [ $a -eq $b ];then
echo "$a equal $b"
else
echo "$a is small than $b"
fi

compare two digital

标签:linux bash

原文地址:http://blog.51cto.com/546136/2073766

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!