Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 7147

Why multiplication sign "*" turns into 0? [duplicate]

$
0
0

I was trying to make a calculator in bash and everything except multiplication works.My script turns "*" into 0 when I try to multiply.There is the code:

#!/bin/bashcalculator(){  if [ $3 = "+" ] ; then    echo [ $1 $3 $2 ]  else     if [ $3 = "-" ] ; then      echo [ $1 $3 $2 ]    else       if [ $3 = "/" ] ; then        echo [ $1 $3 $2 ]      else        if [ $3 = "*" ] ; then          echo [ $1 $3 $2 ]        else          echo "$3 error"        fi              fi    fi  fi}calculator 1 2 *

Viewing all articles
Browse latest Browse all 7147

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>