Hi everyone Today I had to script a bit inside a Linux VM on Azure. I had to make some test inside a bash script. To my extent Iโ€™am not a Linux expert, but I wanted to share a small tip I found. How to find is a variable is empty or unset in BASH ? To find if a variable is SET to empty to a โ€œโ€ string please use the comand : if \[ -z โ€œ\$VARโ€ \]; Another way to write it would be with double bracket : if \[\[ -z \$var \]\] if \[\[ -z โ€œ\$varโ€ \]\] if \[\[ ! \$var \]\] if \[\[ ! โ€œ\$varโ€ \]\] or that expression would check if itโ€™s with a value : if \[\[ \$var \]\] ย  Thanks everyone, enjoy the small tip

Next Post Previous Post