欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

上一篇: Call Bash using Python

下一篇: bash