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 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