Create Multiple Nested Directories in Linux

Did you know that you can create a complete directory tree with one command?

Let’s start with a simple example:

mkdir -p a/b/c

will create this tree:

`-- a
    `-- b
        `-- c

And any of these:

mkdir -p a/{b1,b2}/c

or

mkdir -p a/b{1,2}/c

Will create this tree:

`-- a
    |-- b1
    |   `-- c
    `-- b2
        `-- c

And a little more complicated command:

mkdir -p a/b{1,2,3/c{1,2}}/d

Will create this tree:

`-- a
    |-- b1
    |   `-- d
    |-- b2
    |   `-- d
    `-- b3
        |-- c1
        |   `-- d
        `-- c2
            `-- d

:)

If you enjoyed this post, make sure you subscribe to my RSS feed!

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to Ping.fm Post to Reddit Post to StumbleUpon

Related posts:

  1. Create a Directory Tree With One Command
  2. Renaming Files In Linux
  3. Navigate Efficiently To Your Most Used Directories With Autojump
  4. Fetch Links From Twitter Into Your RSS Reader
  5. Browse the Linux Kernel Source with LXR

Tags: , ,

Friday, July 3rd, 2009 Bash

Leave a Reply

my email
Already a member?
Login
Login using Facebook:
Last visitors
my photo
Hi,
My name is Amir Watad. I have a BSc. in biomedical engineering from The Biomedical Engineering school , Technion , Israel, and am currently studying for a BSc. in electrical engineering at The Electrical Engineering school , Technion , Israel.
I work at the verification dept. in Mellanox Technologies Ltd.
I love Linux, the Command Line and the OpenSource Community.
I used to write Poems (Arabic) when I was able to find time for this.
July 2009
S M T W T F S
« Jun   Sep »
 1234
567891011
12131415161718
19202122232425
262728293031  
Linux Inside
SEO Powered by Platinum SEO from Techblissonline

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.