When do we need curly braces around shell variables?

In this particular example, it makes no difference. However, the {} in ${} are useful if you want to expand the variable foo in the string “${foo}bar” since “$foobar” would instead expand the variable identified by foobar. Curly braces are also unconditionally required when: expanding array elements, as in ${array[42]} using parameter expansion operations, as … Read more