本例子可以在Linux命令行执行命令时,在. shell 后加入输入参数
例子代码如下:
!/bin/bash
if [ $# -lt 2 ]
then echo "usage $0 a b"
exit
fi
a=$1
b=$2
if [ $a -eq $b ]
then echo "$a equals $b"
elif [ $a -gt $b ]
then echo "$a is greater than $b"
else
echo "$a is less than $b"
fi
-------------------------------------------------------
如果不输入参数:. shell 则显示:usage shell a b,即为使用方法提示.
如果在命令行输入执行命令时,并带上输入参数: . shell 4 2,则输出:4 is greater than 2