n与z的比较
-z,! -z与-n的分别
[root@web01-8 scripts]# [ -z "" ] && echo 1||echo 0 #-z表示0为真 1 [root@web01-8 scripts]# [ ! -z "" ] && echo 1||echo 0 0 [root@web01-8 scripts]# [ -n "" ] && echo 1||echo 0 0 [root@web01-8 scripts]# a="abc" [root@web01-8 scripts]# [ -z "$a" ] && echo 1||echo 0 #零为真 0 [root@web01-8 scripts]# [ -n "$a" ] && echo 1||echo 0 1
系统脚本示例:
[root@web01-8 scripts]# sed -n '30,31p' /etc/init.d/network
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 6 #空格冒号
[root@web01-8 scripts]# sed -n '18,22p' /etc/init.d/rpcbind #空格冒号
if [ "$LANG" = "ja" -o "$LANG" = "ja_JP.eucJP" ]; then
if [ "$TERM" = "linux" ] ; then
LANG=C
fi
fi

浙公网安备 33010602011771号