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
$
$
$
$ 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