Bash技巧:对比 test判断字符串是否为空的用法
作者:互联网
#!/bin/bash function empty_string() { if test -n $1; then echo '(1) -n $1 :' "No quote: not empty." fi if [ -z $1 ]; then echo '(2) -z $1 :' "No quote: empty." fi if test -n "$1"; then echo '(3) -n "$1":' "Quote : not empty." fi if [ -z "$1" ]; then echo '(4) -z "$1":' "Quote : empty." fi } empty_string "$1"
标签:No,Quote,echo,Bash,为空,test,fi,empty 来源: https://www.cnblogs.com/qianxiaoPro/p/16245464.html