expr in Shell Script Multiplication Example


In Shell, expr is known as an all-purpose expression evaluator. Command expr concatenates and assesses the arguments according to the operation given. Operations may be arithmetic, comparison, string, or logical. This tutorial explains how to use expr in a shell script for multiplication with syntax and example.


expr expression

expr Multiplication Example

To multiply using expr command use the \* operator. The following example will do multiplication by using the \* operator with expr command.

# Multiplication Example
# ---------- ---------
echo "Multiplication Example"
m=`expr 5 \* 3`
echo "5 * 3 = $m"


Multiplication Example
5 * 3 = 15

See also:

Leave a Comment