Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. #TIL In bash you can create multiple (nested) directories with a single compact line:

#TIL In bash you can create multiple (nested) directories with a single compact line:

Scheduled Pinned Locked Moved Uncategorized
tilbashlinuxcli
16 Posts 13 Posters 88 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • cark@social.tchncs.deC This user is from outside of this forum
    cark@social.tchncs.deC This user is from outside of this forum
    cark@social.tchncs.de
    wrote last edited by
    #1

    #TIL In bash you can create multiple (nested) directories with a single compact line:

    ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

    ❯ tree
    .
    └── a
    ├── b
    ├── c
    │    ├── x
    │   └── y
    └── d
    ├── e
    └── f

    #bash #linux #cli

    jkanev@fediscience.orgJ C daesorin@hachyderm.ioD irom@social.tchncs.deI C 12 Replies Last reply
    2
    0
    • cark@social.tchncs.deC cark@social.tchncs.de

      #TIL In bash you can create multiple (nested) directories with a single compact line:

      ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

      ❯ tree
      .
      └── a
      ├── b
      ├── c
      │    ├── x
      │   └── y
      └── d
      ├── e
      └── f

      #bash #linux #cli

      jkanev@fediscience.orgJ This user is from outside of this forum
      jkanev@fediscience.orgJ This user is from outside of this forum
      jkanev@fediscience.org
      wrote last edited by
      #2

      @cark Thanks!!! Didn't know that.

      1 Reply Last reply
      0
      • System shared this topic
      • cark@social.tchncs.deC cark@social.tchncs.de

        #TIL In bash you can create multiple (nested) directories with a single compact line:

        ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

        ❯ tree
        .
        └── a
        ├── b
        ├── c
        │    ├── x
        │   └── y
        └── d
        ├── e
        └── f

        #bash #linux #cli

        C This user is from outside of this forum
        C This user is from outside of this forum
        creaturaignota@toot.cat
        wrote last edited by
        #3

        @cark neat, isn't it?

        1 Reply Last reply
        0
        • cark@social.tchncs.deC cark@social.tchncs.de

          #TIL In bash you can create multiple (nested) directories with a single compact line:

          ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

          ❯ tree
          .
          └── a
          ├── b
          ├── c
          │    ├── x
          │   └── y
          └── d
          ├── e
          └── f

          #bash #linux #cli

          daesorin@hachyderm.ioD This user is from outside of this forum
          daesorin@hachyderm.ioD This user is from outside of this forum
          daesorin@hachyderm.io
          wrote last edited by
          #4

          @cark Loved your piece on `git fire`. It has inspired me.

          cark@social.tchncs.deC 1 Reply Last reply
          0
          • cark@social.tchncs.deC cark@social.tchncs.de

            #TIL In bash you can create multiple (nested) directories with a single compact line:

            ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

            ❯ tree
            .
            └── a
            ├── b
            ├── c
            │    ├── x
            │   └── y
            └── d
            ├── e
            └── f

            #bash #linux #cli

            irom@social.tchncs.deI This user is from outside of this forum
            irom@social.tchncs.deI This user is from outside of this forum
            irom@social.tchncs.de
            wrote last edited by
            #5

            @cark btw it's called brace expansion. I highly recommend reading the man page of bash, it's all in there! It's loong though.

            1 Reply Last reply
            0
            • daesorin@hachyderm.ioD daesorin@hachyderm.io

              @cark Loved your piece on `git fire`. It has inspired me.

              cark@social.tchncs.deC This user is from outside of this forum
              cark@social.tchncs.deC This user is from outside of this forum
              cark@social.tchncs.de
              wrote last edited by
              #6

              @daesorin Thank you 😊

              Once in a while I have some random insights that I deem worth sharing. However, while I write up those thoughts I usually doubt whether it is worth the effort...

              Therefore, it is really nice to hear that one of those thoughts inspired you that much that you still remember it (and its provenience).

              For other readers: This is the post about the proper usage of in case of 🔥

              #git

              1 Reply Last reply
              0
              • cark@social.tchncs.deC cark@social.tchncs.de

                #TIL In bash you can create multiple (nested) directories with a single compact line:

                ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

                ❯ tree
                .
                └── a
                ├── b
                ├── c
                │    ├── x
                │   └── y
                └── d
                ├── e
                └── f

                #bash #linux #cli

                C This user is from outside of this forum
                C This user is from outside of this forum
                carl@chaos.social
                wrote last edited by
                #7

                @cark modifiziert -p is idempotent, too!
                Like in any Script:

                tempdir_for_script=“/tmp/tempdir_for_$(basename “$0”)

                Later in the script:
                <result to log> >> “$tempdir_for_script”

                Last line of script:
                # rm -r “$tempdir_for_script”

                (Remove # after full debugging)

                1 Reply Last reply
                0
                • cark@social.tchncs.deC cark@social.tchncs.de

                  #TIL In bash you can create multiple (nested) directories with a single compact line:

                  ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

                  ❯ tree
                  .
                  └── a
                  ├── b
                  ├── c
                  │    ├── x
                  │   └── y
                  └── d
                  ├── e
                  └── f

                  #bash #linux #cli

                  matthias@gruene.socialM This user is from outside of this forum
                  matthias@gruene.socialM This user is from outside of this forum
                  matthias@gruene.social
                  wrote last edited by
                  #8

                  @cark tested on OpenIndiana. Works in the same way. Thx!

                  matthias@gruene.socialM 1 Reply Last reply
                  0
                  • matthias@gruene.socialM matthias@gruene.social

                    @cark tested on OpenIndiana. Works in the same way. Thx!

                    matthias@gruene.socialM This user is from outside of this forum
                    matthias@gruene.socialM This user is from outside of this forum
                    matthias@gruene.social
                    wrote last edited by
                    #9

                    @cark and also with fish on cachyos linux.

                    1 Reply Last reply
                    0
                    • cark@social.tchncs.deC cark@social.tchncs.de

                      #TIL In bash you can create multiple (nested) directories with a single compact line:

                      ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

                      ❯ tree
                      .
                      └── a
                      ├── b
                      ├── c
                      │    ├── x
                      │   └── y
                      └── d
                      ├── e
                      └── f

                      #bash #linux #cli

                      compfu@mograph.socialC This user is from outside of this forum
                      compfu@mograph.socialC This user is from outside of this forum
                      compfu@mograph.social
                      wrote last edited by
                      #10

                      @cark Man, curly braces in bash creep me out. I can never remember whether that you need a comma to separate items (because glob expansion produces spaces). If I tried to build that command I would get errors or subfolders called ; 😅

                      1 Reply Last reply
                      0
                      • cark@social.tchncs.deC cark@social.tchncs.de

                        #TIL In bash you can create multiple (nested) directories with a single compact line:

                        ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

                        ❯ tree
                        .
                        └── a
                        ├── b
                        ├── c
                        │    ├── x
                        │   └── y
                        └── d
                        ├── e
                        └── f

                        #bash #linux #cli

                        montyzuma@mastodontech.deM This user is from outside of this forum
                        montyzuma@mastodontech.deM This user is from outside of this forum
                        montyzuma@mastodontech.de
                        wrote last edited by
                        #11

                        @cark Shell expansion magic

                        1 Reply Last reply
                        0
                        • cark@social.tchncs.deC cark@social.tchncs.de

                          #TIL In bash you can create multiple (nested) directories with a single compact line:

                          ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

                          ❯ tree
                          .
                          └── a
                          ├── b
                          ├── c
                          │    ├── x
                          │   └── y
                          └── d
                          ├── e
                          └── f

                          #bash #linux #cli

                          danimrich@mastodon.socialD This user is from outside of this forum
                          danimrich@mastodon.socialD This user is from outside of this forum
                          danimrich@mastodon.social
                          wrote last edited by
                          #12

                          @cark This is a very neat trick of the sort where you learn about it and then spend five minutes thinking of a scenario where it would be useful. 😉

                          1 Reply Last reply
                          0
                          • cark@social.tchncs.deC cark@social.tchncs.de

                            #TIL In bash you can create multiple (nested) directories with a single compact line:

                            ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

                            ❯ tree
                            .
                            └── a
                            ├── b
                            ├── c
                            │    ├── x
                            │   └── y
                            └── d
                            ├── e
                            └── f

                            #bash #linux #cli

                            proedie@mastodon.greenP This user is from outside of this forum
                            proedie@mastodon.greenP This user is from outside of this forum
                            proedie@mastodon.green
                            wrote last edited by
                            #13

                            @cark Whaaaat?! 🤯

                            1 Reply Last reply
                            0
                            • R relay@relay.infosec.exchange shared this topic
                            • cark@social.tchncs.deC cark@social.tchncs.de

                              #TIL In bash you can create multiple (nested) directories with a single compact line:

                              ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

                              ❯ tree
                              .
                              └── a
                              ├── b
                              ├── c
                              │    ├── x
                              │   └── y
                              └── d
                              ├── e
                              └── f

                              #bash #linux #cli

                              jantheowassink@chaos.socialJ This user is from outside of this forum
                              jantheowassink@chaos.socialJ This user is from outside of this forum
                              jantheowassink@chaos.social
                              wrote last edited by
                              #14

                              @cark Brilliant, thanks for sharing!

                              1 Reply Last reply
                              0
                              • cark@social.tchncs.deC cark@social.tchncs.de

                                #TIL In bash you can create multiple (nested) directories with a single compact line:

                                ❯ mkdir -p a/{b,c/{x,y},d/{e,f}}

                                ❯ tree
                                .
                                └── a
                                ├── b
                                ├── c
                                │    ├── x
                                │   └── y
                                └── d
                                ├── e
                                └── f

                                #bash #linux #cli

                                arnotron@noc.socialA This user is from outside of this forum
                                arnotron@noc.socialA This user is from outside of this forum
                                arnotron@noc.social
                                wrote last edited by
                                #15

                                @cark I love brace expressions to create backup copies or rename files. E.g. cp a{,.bak} or me b{,.old}

                                cark@social.tchncs.deC 1 Reply Last reply
                                0
                                • arnotron@noc.socialA arnotron@noc.social

                                  @cark I love brace expressions to create backup copies or rename files. E.g. cp a{,.bak} or me b{,.old}

                                  cark@social.tchncs.deC This user is from outside of this forum
                                  cark@social.tchncs.deC This user is from outside of this forum
                                  cark@social.tchncs.de
                                  wrote last edited by
                                  #16

                                  @arnotron

                                  I was not aware of this technique until recently... and yes I see also there are more use cases e.g. with `cp` and `mv`. 👍

                                  1 Reply Last reply
                                  0
                                  • R relay@relay.infosec.exchange shared this topic
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups