How to create nonexistent subdirectories recursively using Bash?

后端 未结 4 905
悲哀的现实
悲哀的现实 2020-11-30 17:59

I am creating a quick backup script that will dump some databases into a nice/neat directory structure and I realized that I need to test to make sure that the directories e

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 18:08

    While existing answers definitely solve the purpose, if your'e looking to replicate nested directory structure under two different subdirectories, then you can do this

    mkdir -p {main,test}/{resources,scala/com/company}
    

    It will create following directory structure under the directory from where it is invoked

    ├── main
    │   ├── resources
    │   └── scala
    │       └── com
    │           └── company
    └── test
        ├── resources
        └── scala
            └── com
                └── company
    

    The example was taken from this link for creating SBT directory structure

提交回复
热议问题