What is the use of curly braces {} in bash variable

Bash variables with and with out curly braces are similar in nature. Because the the first one is a simplified version of the second.

According to POSIX.1-2008 section 2.6.2, the curly braces are optional in bash variables.

But there are some advantages if the variable is inside the curly braces.

In-order to access one element from an array, bash variable requires the curly braces {}.

Also this is required in parameter expansion operations in bash.

That's all…

Leave a Reply