Shell Script : command not found error -


#!/bin/bash  calc() {         n1=$1         op=$2         n2=$3         ans=0          if [ $# -eq 3 ]                                 $ans=$(expr $n1 $op $n2);                 echo "$n1 $op $n2 = $ans"                 return $ans         else                 echo "needs 3 parameters!"         fi          return;  } 

i googled alot still can not find error in code, know simple code please me i'm totally new , trying self study.

the error

line 12: 0=11: command not found 

thank in advance

the error coming '$ans' on line

 $ans=$(expr $n1 $op $n2); 

should

ans=$(expr $n1 $op $n2); 

the '$' evaluating variable 'ans', result instead of assigning result variable 'ans', trying assign result '0'.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -