判断变量为空
1、
if [ ! -n "$word" ] ;then
echo "you have not input a word"
else
echo "the word you input is $word"
fi
2、直接判断
if [ ! "$word" ] ;then
echo "you have not input a word"
else
echo "the word you input is $word"
fi
3、通过test判断
if test -z "$word" ;then
echo "you have not input a word"
else
echo "the word you input is $word"
fi
4、使用”“判断
if [ "" = "$word" ] ;then
echo "you have not input a word"
else
echo "the word you input is $word"
fi
输入参数把$word改成$1即可