Linux中if话语的使用

Linux中if话语的使用

Linux中if语句的使用

-eq ==

-ne !=

-lt <

-le <=

-gt >

-ge >=

<li>编写一脚本if.sh

#!/bin/sh

if test $1 -eq $2; then

echo $1 ‘==(-eq)’ $2

else

if test $1 -ne $2;then

echo $1 ‘!=(-ne)’ $2

fi

if test $1 -lt $2;then

echo $1 ‘<(-lt)’ $2

fi

if test $1 -gt $2;then

echo $1 ‘>(-gt)’ $2

fi

fi

<li>运行如下

chmod a+x if.sh

命令:./if.sh 2 2

结果:2 ==(-eq) 2

命令:./if.sh 1 2

结果:1 !=(-ne) 2

1 <(-lt) 2

命令:./if.sh 2 1

结果:2 !=(-ne) 1

2 >(-gt) 1

Linux中if话语的使用

相关文章:

你感兴趣的文章:

标签云: