if [[ -n $VAR ]]; then ... fi

Category: Bash Scripting

if [[ -n $VAR ]]; then ... fi

Check if a variable is non-empty

Checks if a variable has a value (is non-empty). -n means 'non-zero length string'.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.