Custom Search

Wednesday, March 13, 2013

shellscript how to check whether a variable is empty or not

shellscript how to check whether a variable is empty or not
$
$ MYVAR=""
$
$
$ if [ -z $MYVAR ]; then echo "Empty"; else echo "Not Empty"; fi
Empty
$
$
$ MYVAR="sometext"
$
$
$ if [ -z $MYVAR ]; then echo "Empty"; else echo "Not Empty"; fi
Not Empty
$
$

No comments:

Post a Comment