Bash If Statement With Multiple Conditions Throws An Error
Answer : Use -a (for and) and -o (for or) operations. tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html Update Actually you could still use && and || with the -eq operation. So your script would be like this: my_error_flag=1 my_error_flag_o=1 if [ $my_error_flag -eq 1 ] || [ $my_error_flag_o -eq 2 ] || ([ $my_error_flag -eq 1 ] && [ $my_error_flag_o -eq 2 ]); then echo "$my_error_flag" else echo "no flag" fi Although in your case you can discard the last two expressions and just stick with one or operation like this: my_error_flag=1 my_error_flag_o=1 if [ $my_error_flag -eq 1 ] || [ $my_error_flag_o -eq 2 ]; then echo "$my_error_flag" else echo "no flag" fi You can use either [[ or (( keyword. When you use [[ keyword, you have to use string operators such as -eq , -lt . I think, (( is most preferred for arithmetic, because you can directly use operators such as == , < and ...