mardi 9 octobre 2018

bash error: syntax error: invalid arithmetic operator

I am comparing two array variables where the value of these variables contains two arithmetic character "-" (minus / hyphen) and "." (dot).

the code looks like below

if [ "${tbls_t[i]}" == "${limit_t[j]}" ];

The variable "tbls_t[i]" has value prod.mytblnm.REG2.32d64d74-733f-4fed-bf4b-d57b90d5286b The other variable limit_t[j] has the same value. Logically these there should not be any error, but since the values contain arithmetic operators "-" and ".", that may be the reason for the error. The error received is as below.

./myscript.sh: line 33: prod.mytblnm.REG2.32d64d74-733f-4fed-bf4b-d57b90d5286b: syntax error: invalid arithmetic operator (error token is ".mytblnm.REG2.32d64d74-733f-4fed-bf4b-d57b90d5286b")

Can someone tell me how i can resolve this.

Aucun commentaire:

Enregistrer un commentaire