hp ux - Hp-Ux.Shell.Using variables in "if" -


recently i've got confused following situation. difference between 2 if usage:

case 1

amount=10   if [[ $amount -eq 10 ]]          echo "something"   fi   

script output:

$ ./1.sh     

case 2

if [[ amount -eq 10 ]]    

this works (note variable name doesn't contain $).

so question how work without dollar sign in variable name.

p.s. i'm using posix shell on hp-ux.

man bash

arithmetic evaluation ... shell variables allowed operands; parameter expansion per‐ formed before expression evaluated. within expression, shell variables may referenced name without using parameter expansion syntax.

in context shell not expect numerics, expands strings variables. makes sense me.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -