Shell realizes four arithmetic operations by passing parameters

#!/bin/bash 

read X OPT Y
if [ "$OPT" == "*" ]
then
	echo `expr $X \* $Y`
else
	echo `expr $X $OPT $Y`
fi

Test Results

Insert picture description here

Guess you like

Origin blog.csdn.net/zxy131072/article/details/108527953