Bash shell find out if a variable has NULL value OR not

#1

Originally published at: https://www.cyberciti.biz/faq/bash-shell-find-out-if-a-variable-has-null-value-or-not/

I am a new to shell scripting. How do I check for NULL value in a Linux or Unix shell scripts?

0 Likes

#2

You can use this way:

my_str="test"
if [[ ${my_str} ]]; then
  echo " Has a value"
else
  echo "No value"
fi
1 Like