Hello!
I have written a simple Bash calculator that operates with values given as parameters. In short, you give the operation as the first parameter, the first int as the second parameter and the other int as the third parameter. And it works.
How could I get it work with ANY number of parameters? Like the user gives a "+" as the first parameter, then 7 other numbers and it sums them up.
I have written a simple Bash calculator that operates with values given as parameters. In short, you give the operation as the first parameter, the first int as the second parameter and the other int as the third parameter. And it works.
Code
#!\bin\bash
op="$1"
nf="$2"
ns="$3"
#Arguments are stored in these variables for future usage
echo `expr $nf $op $ns`How could I get it work with ANY number of parameters? Like the user gives a "+" as the first parameter, then 7 other numbers and it sums them up.
Regards from
![[Image: qp0UIPa.png]](https://i.imgur.com/qp0UIPa.png)
The Society

