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:
6
bash.md
6
bash.md
@@ -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
|
||||
|
Reference in New Issue
Block a user