All of the above 100% correct. But it goes a little deeper, and the $ prefix is more functional than has been explained.
1 - variable concatination.
${ORACLE_HOME} this will evaluate that variable, say /home/oracle
${ORACLE_HOME}XXX This will evaluate ${ORACLE_HOME} & ADD XXX so, /home/oracleXXXX.
${ORACLE_HOME}/${MY_SCRIPTS} would concatanate the whole string to say, /home/Oracle/scripts/bin (assuming MY_SCRIPTS=scripts/bin).
The reason for the curly brackets ${} is to explicitly define the variable. e.g. you COULD have used $ORACLE_HOMEXXX . this would NOT work as there is no (well it is unlikley) to be a varable called "ORACLE_HOMEXXX". The backets allow explicit variable concatination.
2 - variable substitution.
Sometimes you want to read the result of a command into a variable e.g.
$TDAY --> todays date.
This can be done like so
export TDAY = $(date)
Now $TDAY has todays date in it. In effect the $(..cmd..) executes the command and presents it to the shell as a variable, (as opposed to standard error or standard out) so the following is equally valid (but trivial)
echo $(date)
I fully admit that the above is trivial, but it can be useful in more complex scripts. Imagine that you wanted to print out all the logical volumes you have in vg01. You can list all the logical volume names using vgdisplay -v vg01|grep "LV Name"; but this is not enough as you want ALL the info for each LV (without doing each one manually)... so
for lv in $( /etc/vgdispalay -v vg01| perl -ane 'if (m/LV Name/) { print "$F[2] "})
do
/etc/lvdisplay $lv
done
IF you were not allowed to use the structure $( ..cmd.. ) then the only other way of doing this would be to output the above commands to a file & read it back into a for;do;done loop. This would be slower as it needs to write the data to disks as opposed to doing the whole operation in memory.
Anyway.. the $VAR; ${VAR}; and $( ..cmd.. ) structures are very useful..
Regards
Tim
-