Created
April 20, 2021 04:14
-
-
Save slaveofcode/0f4d4ec9841e4b49b880d7e8dd1925fc to your computer and use it in GitHub Desktop.
if conditions for checking variable was set or exist on shell script
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/sh | |
a=1 | |
b=2 | |
# #Check whether they are equal | |
# if [ $a = $b ] | |
# then | |
# echo "a is equal to b" | |
# fi | |
if [ ! -z "$a" ] && [ ! -z "$b" ]; | |
then | |
echo "a & b exist" | |
elif [ ! -z "$a" ]; then | |
echo "a exist" | |
elif [ ! -z "$b" ]; then | |
echo "b exist" | |
else | |
echo "a and/or b not exist" | |
fi | |
#Check whether they are not equal | |
# if [ $a != $b ] | |
# then | |
# echo "a is not equal to b" | |
# fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment