Is variable empty bash?

Đức Linh

New member
Is variable empty bash?
Answer
To find out if a bash variable is empty:
Return true if a bash variable is unset or set to the empty string: if [ -z “$var” ]; Another option: [ -z “$var” ] && echo “Empty” Determine if a bash variable is empty: [[ ! -z “$var” ]] && echo “Not empty” || echo “Empty”
 

Tìm kiếm

Back
Top