-n STRING (conditional operator)
true
if the string is not empty, i.e. if its length is non-zero.
This is usually only useful for strings, which contain variables or sub-expressions.
-z
tests if a string is empty.
Links
Examples
- Different ways to test if a string is not empty:
1 2 3 4
test -n "$name" && echo "not empty" [ -n "$name" ] && echo "not empty" # Bash [[ -n "$name" ]] && echo "not empty"
BashSupport Pro ist eine Bash IDE mit Unterstützung für -n – probieren Sie es aus!