shell - Test for non-zero length string in Bash: [ -n "$var" ] or [ "$var" ] - Stack Overflow

PHOTO EMBED

Fri Mar 04 2022 21:20:17 GMT+0000 (UTC)

Saved by @joel113 #sh #bash

if [[ $var ]]; then   # var is set and it is not empty
if [[ ! $var ]]; then # var is not set or it is set to an empty string
content_copyCOPY

https://stackoverflow.com/questions/3869072/test-for-non-zero-length-string-in-bash-n-var-or-var