Chinaunix

标题: 判断变量为空的两种方法有什么区别 [打印本页]

作者: deepalley    时间: 2012-03-19 10:30
标题: 判断变量为空的两种方法有什么区别
  1. if [ "x$hostname" == "x" -o "x$hostname" == "x(none)" ];then
复制代码
请教这一行中两个判断条件有什么区别,后面这个none一般用在什么场景,很少见到这种用法,请大侠们指教。
         
作者: nuclearxin    时间: 2012-03-19 11:17
$hostname="(none)";#string
$hostname="" ; #null


作者: deepalley    时间: 2012-03-19 11:45
回复 2# nuclearxin


    我用-x 看none也没啥特别意思  看来我被忽悠了?




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2