-z STRING (conditional operator)

true if the string is empty, i.e. if its length is zero. This is usually only useful for strings, which contain variables or sub-expressions.

-n tests if a string is not empty.

Examples

Different ways to test if a string is empty:
1
2
3
4
test -z "$name" && echo "empty"
[ -z "$name" ] && echo "empty"
# Bash
[[ -z "$name" ]] && echo "empty"
BashSupport Pro ist eine Bash IDE mit Unterstützung für -zprobieren Sie es aus!
© 2020–2024 Joachim Ansorg
Impressum
Datenschutz
Rechtliches