linux-tutorial/codes/linux/shell-demos/statement/ifDemo.sh
2019-02-22 19:24:00 +08:00

28 lines
378 B
Bash

#!/usr/bin/env bash
if [[ -z $1 ]]; then
echo "please input first param";
exit
fi
if [[ -z $2 ]]; then
echo "please input second param";
exit
fi
if [[ $1 > $2 ]]; then
echo "\$1 > \$2";
elif [[ $1 < $2 ]]; then
echo "\$1 < \$2";
else
echo "\$1 != \$2";
fi
# execute: ./ifDemo.sh abc abc
# output:
# $1 == $2
# execute: ./ifDemo.sh abc ab
# output:
# $1 != $2