shell判断输入变量或者参数是否为空
判断变量为空
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