How do I make multiple directories at once in a directory?
The {}
syntax is Bash syntax not tied to the for
construct.
mkdir {A..Z}
is sufficient all by itself.
http://www.gnu.org/software/bash/manual/bashref.html#Brace-Expansion
It's probably easiest to just use a for
loop:
for char in {A..Z}; do
mkdir $char
done
for num in {1..100}; do
mkdir $num
done
You need at least bash 3.0 though; otherwise you have to use something like seq
You can also do more complex combinations (try these with echo
instead of mkdir
so there's no cleanup afterwards):
Compare
$ echo pre-{{F..G},{3..4},{m..n}}-post
pre-F-post pre-G-post pre-3-post pre-4-post pre-m-post pre-n-post
to
$ echo pre-{F..G}{3..4}{m..n}-post
pre-F3m-post pre-F3n-post pre-F4m-post pre-F4n-post pre-G3m-post pre-G3n-post
pre-G4m-post pre-G4n-post
If you have Bash 4, try
$ echo file{0001..10}
file0001 file0002 file0003 file0004 file0005 file0006 file0007 file0008 file0009
file0010
and
$ echo file{0001..10..2}
file0001 file0003 file0005 file0007 file0009