mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-12 17:54:26 +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:
6
bash.md
6
bash.md
@@ -175,6 +175,12 @@ fi
|
|||||||
if [[ "$name" == "Daniya" ]] || [[ "$name" == "Zach" ]]; then
|
if [[ "$name" == "Daniya" ]] || [[ "$name" == "Zach" ]]; then
|
||||||
echo "This will run if $name is Daniya OR Zach."
|
echo "This will run if $name is Daniya OR Zach."
|
||||||
fi
|
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:
|
# There are other comparison operators for numbers listed below:
|
||||||
# -ne - not equal
|
# -ne - not equal
|
||||||
# -lt - less than
|
# -lt - less than
|
||||||
|
Reference in New Issue
Block a user