Skip to main content
4 of 4
fixing the answer

Try it:

> for name in {Regular,Italic,Bold-Italic}; do echo $name;done
Regular
Italic
Bold-Italic

The element {1,2,3} is called brace expansion. Basically your shell expands this element and uses each produced entry into the for loop (see here for more info about brace expansion). If you don't use {}, the shell will understand 1,2,3 as a single element, and would get through in the loop only once, producing

❯ for name in Regular,Italic,Bold-Italic; do echo $name;done
Regular,Italic,Bold-Italic

which is not what you are probably expecting...

Alternatively, you can also use brace expansion to create a sequence using the following notation

❯ for i in {1..5}; do echo $i; done
1
2
3
4
5

It is worth to mention that you can create different strings with a sequence pattern using brace expansion and use it into the for loop, as shown here:

❯ for i in A{1..5}BC; do echo $i; done
A1BC
A2BC
A3BC
A4BC
A5BC