Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

what is the difference between braces and normal brackets in bash?

FYI... I did not get it in the related questions list and also not able to locate it in questions search. Please point me to the question if it has been already asked.

share|improve this question
Very creative terminology. – John Gardeniers Apr 21 '10 at 8:23

Braces are used for parameter expansion (${foo%123}), brace expansion in either alternate ({foo,bar}) or sequence forms ({1..25}), or in blocks of code ({ foo ; bar ; }).

Square brackets are used as comparison commmands ([ "$foo" -lt 3 ], [[ $bar =~ ^123 ]]), As a range or character class in a glob (ba[rz], foo[[:alnum:]], qu[[=u=]]x), as part of an array assignment (foo=([2]=3 4 5), foo[42]=bar), or in parameter expansion when dealing with an array (${foo[@]}).

In other words, they're completely different.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.