A bitwise operator is an operator which used to perform bitwise operations on bit patterns. It converts the operands into binary data and then perform necessary operations bit by bit. Bitwise operators are of 6 types,
Bitwise AND ( & ) :
A Bitwise AND operator performs binary AND operation bit by bit on the operands.
It converts the given input to binary digit and then perform AND operation bit by bit. Finally it returns the decimal value.
BOR=$(( $val1 | $val2 ))
echo Bitwise OR of $val1 and $val2 is $BOR
Run the file,
Enter val1 : 36
Enter val2 : 72
Bitwise OR of 36 and 72 is 108
Bitwise XOR ( ^ ) :
Bitwise ^ operator performs binary XOR operation bit by bit on the operands.
It converts the given input to binary digit and then perform XOR operation bit by bit. It compares both operands and returns 1 if both are different and it returns 0 if both the operands are same. Finally it returns the decimal value of the result.