当前位置: 技术问答>linux和unix
判断字符串是否为空,请问为啥结果不一样
来源: 互联网 发布时间:2016-10-18
本文导语: #!/bin/bash tmp=`ps -ef|grep abcd|grep -v grep|awk '{print $2}'` if [ -n $tmp ] then echo "tmp is not null" else echo "tmp is null" fi if [ -z "$tmp" ] then echo "tmp is null" fi if [ $tmp="" ] then echo "tmp is null" fi if [ $tmp!="" ] then echo "tmp is ...
#!/bin/bash
tmp=`ps -ef|grep abcd|grep -v grep|awk '{print $2}'`
if [ -n $tmp ]
then
echo "tmp is not null"
else
echo "tmp is null"
fi
if [ -z "$tmp" ]
then
echo "tmp is null"
fi
if [ $tmp="" ]
then
echo "tmp is null"
fi
if [ $tmp!="" ]
then
echo "tmp is not null"
fi
|
#!/bin/bash
tmp=`ps -ef|grep abcd|grep -v grep|awk '{print $2}'`
if [ -n "$tmp" ]
then
echo "tmp is not null"
else
echo "tmp is null"
fi
if [ -z "$tmp" ]
then
echo "tmp is null"
fi
if [[ $tmp = "" ]]
then
echo "tmp is null"
fi
if [[ $tmp != "" ]]
then
echo "tmp is not null"
fi
|
if [ $tmp!="" ]
应该是
if [[ $tmp!="" ]]