I'm trying to make a rather simple bash script where if the input is "on 1" it will execute an action and if it is "on 2" it will execute another action. I did a bit of googling about to find out how people were making the and operator work in bash scripts, I found a lot of different ways and none of them seemed to work, until I found to replace my brackets with parentheses().
#!/bin/sh # if (($1=="on" && $2=="1")); then echo $1 $2 else echo failure fi
Once I got that far, what happens is that my script is accepting the second argument, but not the first. So if I write "off 1" the script gets executed even if $1 wasn't "on" like the if should be demanding, however if I write "on 2" the code jumps to my else statement.
How do I make it read both arguments properly instead of only the second?