Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I know with mkdir I can do mkdir A B C D E F to create each directory. How do I create directories A-Z or 1-100 with out typing in each letter or number?

share|improve this question
up vote 14 down vote accepted

It's probably easiest to just use a for loop:

for char in {A..Z}; do
    mkdir $char

for num in {1..100}; do
    mkdir $num

You need at least bash 3.0 though; otherwise you have to use something like seq

share|improve this answer
Michael thanks! being curious I also tried it adding test in front of $char for char in {A..Z}; do mkdir test$char done which gave me directories test[A-Z], always good to learn – Steve Burdine Aug 18 '10 at 1:48
One thing to keep in mind is how your file names will be sorted when you list them or use them with wildcards like *. '11' will sort before '2'. This can be avoided if you arrange for all the numbers to be the same length with leading zeros. Dennis Williams shows how to do that in bash 4, but you can code your script to do it if you don't have bash 4. – Joe Dec 11 '11 at 6:45

The {} syntax is Bash syntax not tied to the for construct.

mkdir {A..Z}

is sufficient all by itself.


share|improve this answer
Oh, that's spectacular. This is a much better answer – Michael Mrozek Aug 18 '10 at 1:58
I didn't know this, great tip! – invert Aug 18 '10 at 9:34
+1 for beauty, +1 for style, +1 for rcrowley – Stefan Sep 16 '10 at 10:02
+500 bounty from me. – Buk Lau Dec 24 '15 at 17:41
This is awesome! just used it: mkdir -p ./logs-{1..5} – Pranav 웃 Jan 17 at 6:22

You can also do more complex combinations (try these with echo instead of mkdir so there's no cleanup afterwards):


$ 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


$ 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


$ echo file{0001..10..2}
file0001 file0003 file0005 file0007 file0009
share|improve this answer

On Linux you can generate sequences of digits with the "seq" command, but this doesn't exist on all Unix systems. For example to generate directories from 1 to 100:

mkdir `seq 1 100`

While you can certainly make directories A to Z with shell utils:

seq 65 90 \
    | while read foo; do printf "%b\n" `printf '\\\\x%x\n' $foo`; done \
    | xargs mkdir

It's probably a lot less ugly to just use Perl:

perl -e 'foreach (ord "A"..ord "Z") { mkdir chr $_ }'
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.