Last Updated: February 25, 2016
·
320
· victorbrca

Use Bash's built-in brace expansion to display a sequence of numbers

Use Bash's built-in brace expansion to display a sequence of numbers.

So "echo {1..5}" will expand to "1 2 3 4 5".

$ echo {1..5}
1 2 3 4 5

You can also expand alphabet letters

$ echo {a..e}
a b c d e

Combine alpha and numeric

$ echo {a..e}{1..5}
a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 c1 c2 c3 c4 c5 d1 d2 d3 d4 d5 e1 e2 e3 e4 e5

Use it as prefix or suffix

$ echo file{1..5}.txt
file1.txt file2.txt file3.txt file4.txt file5.txt

Download files

$ wget http://domain.com/track{1..5}.mp3