i have seen in many script usage of "$var"
and "${var}"
, so I just want to know diffrence between "$var"
and "${var}"
Asked
Active
Viewed 489 times
1

Rahul Patil
- 24,711
1 Answers
5
The braces explicitly denote the beginning and end of the parameter syntax, otherwise, there is no difference. This makes certain statements unambiguous, for example:
$ foo=bar
$ echo "$fooa" # Is this $foo + a, or $fooa?
$ echo "${foo}a"
bara

Chris Down
- 125,559
- 25
- 270
- 266
echo "$foo"a
then why braces in used? – Rahul Patil Feb 13 '13 at 08:18"
is an illegal character in a variable name, so it terminates there. – Chris Down Feb 13 '13 at 08:23fooa
variable. Bash is not DWIM-compatible :) – l0b0 Feb 13 '13 at 09:17