Unexpected behavior of expr

expression, linux, shell

Solution

You need to quote the `*`, because otherwise the shell attempts file name expansion.

$ expr 3 '*' 2
6

Problem

It may sound a bit trivial but it actually is quite frustrating: Can anyone explain me this: ``` [~:user$]expr 3 + 2 6 [~:user$]expr 3 / 2 1 [~:user$]expr 3 * 2 expr: syntax error ``` When the man page for `expr` precisely specifies that ARG1 * ARG2 is arithmetic product of both. Thanks,

Original source