Shell Script : How to check if variable is null or no

Try following, you should change from -z to -n as follows and add $ to your variable too.

if [[ -n "$list_Data" ]]
then
    echo "not Empty"
else
    echo "empty"
fi

Explanation: From man test page as follows(It checks if a variable is having any value or not. If it has any value then condition is TRUE, if not then it is FALSE.)

   -n STRING
          the length of STRING is nonzero

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)