linux-tutorial/codes/bash/statement/ifDemo.sh

26 lines
335 B
Bash
Raw Normal View History

2017-11-17 17:06:52 +08:00
#!/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";
else
echo "\$1 != \$2";
fi
# execute: ./ifDemo.sh abc abc
# output:
# $1 == $2
# execute: ./ifDemo.sh abc ab
# output:
# $1 != $2