How to create calculator with bash?

How to create calculator with bash ?

example

    read -p "calculator count: "  calc
    echo '$((calc))' | bc

i input

2+2

output

(standard_in) 1: illegal character: $

how to fix ?

I just want to make text input in the script, so for the addition of + , - , x - and / . I input manually

for example I want 2+2+1*3/2

After I enter, the result will appear


As already pointed out by Terrance, you need double quotes; otherwise, the $ sign is sent literally.

Also, remove the double parentheses which ask Bash to do the calculation. In which case you wouldn't need to pipe to bc, but Bash only does integer arithmetic.

So it should be either

echo "$((calc))" # evaluated by Bash

or

echo "$calc" | bc