How to find if a bash variable is empty?

If you want to know if a bash variable is empty , there are multiple ways to do it and this blog post explains how to do with the recommended way.

How to determine if a bash variable is empty?

if [ -z "${VAR}" ];

The above code snippet returns trus if a variable is unset (called null in programming terms) or if it is set to empty string.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Hey, wait!Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.