value1=true
value2=false
#true and false are also commands, so the variable itself is a condition
#(only for a variable set in the script: its value is run as a command);
#! inverts the exit code, && and || join the conditions
! $value1 && valueNot1=true || valueNot1=false
#valueNot1 is false
! $value2 && valueNot2=true || valueNot2=false
#valueNot2 is true
$value1 && $value2 && valueAnd=true || valueAnd=false
#valueAnd is false
#{ } groups the conditions, as the brackets do in other languages
{ $value1 || $value2; } && valueOr=true || valueOr=false
#valueOr is true
#there is no logical xor: compare the words
[[ "$value1" != "$value2" ]] && valueXor=true || valueXor=false
#valueXor is true
#in (( )) the numbers 1 and 0 are the truth, as in C, and ^ is xor;
#$(( one && zero )) itself gives the number 0
one=1
zero=0
(( one && zero )) && arithAnd=true || arithAnd=false
#arithAnd is false
(( one ^ zero )) && arithXor=true || arithXor=false
#arithXor is true
echo "valueNot1 is $valueNot1"
echo "valueNot2 is $valueNot2"
echo "valueAnd is $valueAnd"
echo "valueOr is $valueOr"
echo "valueXor is $valueXor"
echo "arithAnd is $arithAnd"
echo "arithXor is $arithXor"