I want to do something like below in Bash script. How do I implement it in Bash syntax?
if !((a==b) && (a==c))
then
# Do something
end if
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For numeric comparison, you can do:
For string comparison:
In Bash, the double parentheses set up an arithmetic context (in which dollar signs are mostly optional, by the way) for a comparison (also used in
for ((i=0; i<=10; i++))and$(())arithmetic expansion) and is used to distinguish the sequence from a set of single parentheses which creates a subshell.This, for example, executes the command
trueand, since it’s always true it does the action:This is the same as
except that a subshell is created. However,
if ((true))tests the value of a variable named “true”.If you were to include a dollar sign, then “$true” would unambiguously be a variable, but the
ifbehavior with single parentheses (or without parentheses) would change.or
would execute the contents of the variable as a command and execute the conditional action based on the command’s exit value (or give a “command not found” message if the contents aren’t a valid command).
does the same thing as
if ((true))as described above.