Is Null in Unix?
Contents How Do You Check If a Variable Is Null in Unix? to Find out If a Bash Variable Is Null: Return True If a Bash Variable Is Unset or Set to the Null...
Contents
How do you check if a variable is null in Unix?
To find out if a bash variable is null:
- Return true if a bash variable is unset or set to the null (empty) string: if [ -z “$var” ]; then echo “NULL”; else echo “Not NULL”; fi.
- Another option to find if bash variable set to NULL: [ -z “$var” ] && echo “NULL”
- Determine if a bash variable is NULL: [[ !
27 дек. 2018 г.
Must Read
What is null Linux?
/dev/null in Linux is a null device file. This will discard anything written to it, and will return EOF on reading. This is a command-line hack that acts as a vacuum, that sucks anything thrown to it.