bash

2016-11-16  本文已影响0人  vanhukset
##读取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
#*************************
上一篇下一篇

猜你喜欢

热点阅读