Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between $VARIABLE and ${VARIABLE}

Can anyone please provide me an explanation as to why some Linux expert suggest that we use ${VARIABLE} in Bash scripts? There doesn't seem to be any difference at all.

like image 623
爱国者 Avatar asked Nov 24 '11 09:11

爱国者


1 Answers

Say you want to print $VARIABLE immediately followed by "string"

echo "$VARIABLEstring"    # tries to print the variable called VARIABLEstring
echo "${VARIABLE}string"  # prints $VARIABLE and then "string"

Bash also supports string manipulation using this syntax.

like image 60
cnicutar Avatar answered Oct 05 '22 08:10

cnicutar