Created
October 12, 2021 11:58
-
-
Save moalex/63a67c7126819ed2c9d846abd8e50525 to your computer and use it in GitHub Desktop.
bash :: Пустая ли строка
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
val1="testing" | |
val2='' | |
### Не пустая ли строка | |
if [ -n $val1 ]; then | |
echo "Строка '$val1' не пустая" | |
else | |
echo "Строка '$val1' пустая" | |
fi | |
### Пустая ли строка | |
if [ -z $val2 ]; then | |
echo "Строка '$val2' пустая" | |
else | |
echo "Строка '$val2' не пустая" | |
fi | |
if [ -z $val3 ]; then | |
echo "Строка '$val3' пустая" | |
else | |
echo "Строка '$val3' не пустая" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment