Brace expansion is used to generate a series of words or letters separated by ,
comma, or ..
2 periods.
-
..
2 periods will set a range from x to x position. -
,
comma will generate a series of specific filenames or letters.
To generate series A to F letters.
1
2
echo {A..F} # ==>> A B C D E F
echo {a..f} # ==>> a b c d e f
To generate series 1 to 10 numbers.
1
echo {1..10} # ==>> 1 2 3 ... 10
To skip numbers between 5 and 50 then use the 3rd option which is optional but good to use when you want skipping values.
1
echo {5..50..5} # ==>> 5 10 15 .... 50
To generate a series of specific letters.
1
echo {x,y}.js # ==>> x.js y.js
To generate a series of multiple filenames with extension.
1
2
echo {x,y}.{js,txt} # ==>> x.js x.txt y.js y.txt
echo {base,index}.{js,rb} # ==>> base.js base.rb index.js index.rb
To create a series of files at once use the touch
command.
1
2
3
4
touch {x,y}.{js,txt}
touch {base,index}.{js,rb}
touch file{1..3}.txt
touch {A..F}-{1..3}.txt