1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-10 00:36:48 +02:00

[bash/en] Added -z and -n string conditional operators (#5307)

* Added -z and -n string conditional operators

* Fix typo
This commit is contained in:
Deniss Samcuks
2025-05-09 16:14:32 +03:00
committed by GitHub
parent f999f09807
commit 964a539453

View File

@@ -175,6 +175,12 @@ fi
if [[ "$name" == "Daniya" ]] || [[ "$name" == "Zach" ]]; then
echo "This will run if $name is Daniya OR Zach."
fi
# To check if a string is empty or not set use -z and -n to check if it is NOT empty
if [[ -z "$name" ]]; then
echo "Name is unset"
fi
# There are other comparison operators for numbers listed below:
# -ne - not equal
# -lt - less than