bash
程序员文章站
2022-07-14 13:29:02
...
##读取2个数字,比较大小
read x;
read y;
if (( x>y ));
then
echo "X is greater than Y";
elif (( x==y));
then
echo "X is equal to Y";
else
echo "X is less than Y";
fi;
#-------------------------------------
##Bash If..then..fi statement
if [ conditional expression ]
then
statement1
statement2
.
fi
##例如
#!/bin/bash
count=100
if [ $count -eq 100 ]
then
echo "Count is 100"
fi
#*************************
#-------------------------------------
######Bash If..then..else..fi statement
If [ conditional expression ]
then
statement1
statement2
.
else
statement3
statement4
.
fi
##example
#!/bin/bash
count=99
if [ $count -eq 100 ]
then
echo "Count is 100"
else
echo "Count is not 100"
fi
#*************************
转载于:https://www.jianshu.com/p/da0c605af92c
下一篇: bash