-1
Hello, I’m trying to create a comparison where the next action will be different for each variable value someone can help me.
The intention is if the value is true, executes one function if it is false executes another, but need to compare 4 variables in the same block only 1 can be true the others have to return false.
Follow my code:
attributes phones of each server
act1="$vartest1" act2="$vartest2" act3="$vartest3" act4="$vartest4"
if [ "$act1" == "test" ] then echo "Truth" Else echo "False"
Elif [ "$act2" == "false" ] then echo "False" Sleep 1s Else echo "Truth"
Elif [ "$act2" == "false" ] then echo "False" Else echo "Truth"
tested here did not work out in shell we used Elif I wanted to compare the results if 4 different variables only 1 is true it executes the command if not it executes another command.
– Victor
As far as I know it would be by the if syntax same, you could use the case, for example, but I use it in JS do not know if have in Shel
– DbaAlone