0

I wonder what is a difference between $VARNAME and ${VARNAME} in bash ?

codeforester
  • 39,467
  • 16
  • 112
  • 140
mrgloom
  • 20,061
  • 36
  • 171
  • 301
  • 3
    One question to a question. You can ask about whether curly braces make a difference, or about single-vs-double-quotes, but putting both in one question is too broad. – Charles Duffy Jan 31 '17 at 17:03
  • For your second question, try `foo="$bar"` and `foo='$bar'` (where `bar` has already been defined), and you should see the difference. – Kevin Jan 31 '17 at 17:04
  • Please refer to:
    https://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash
    – Shreyas Gokhale Jan 31 '17 at 17:05
  • btw -- all-caps variable names are actually used for variables with meaning to the operating system or shell; lowercase names are reserved for application use, and are thus generally what you should be using in your own code. See http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html, fourth paragraph (the spec is re: environment variables, but setting a regular shell variable automatically overwrites any like-named environment variable, making the convention necessarily apply in both places). – Charles Duffy Jan 31 '17 at 17:06

0 Answers0