Forrest logo
back to the expr tool

expr:tldr:668e2

expr: Get the first expression if both expressions are non-zero and not null otherwise get zero.
$ expr ${expression1} \& ${expression2}
try on your machine

The command "expr ${expression1} \& ${expression2}" is a Unix/Linux command used for performing bitwise AND operation between two expressions or variables.

Here's the breakdown:

  • "expr" is the command used for evaluating expressions and performing various operations.
  • "${expression1}" and "${expression2}" are placeholders for the expressions or variables whose bitwise AND operation needs to be performed.
  • The backslash "\" before the ampersand "&" is used to escape the special meaning of the ampersand character and treat it as a literal character.
  • The ampersand "&" represents the bitwise AND operator.

When this command is executed, it will evaluate the given expressions or variables and perform a bitwise AND operation on their corresponding bits. The result will be printed as an output of the command.

For example, if expression1 is 5 (binary representation: 101) and expression2 is 3 (binary representation: 011), the bitwise AND operation would be: 101 & 011

001

Therefore, the output of the command would be "1" (binary representation: 001).

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the expr tool