Unix - create path of folders and file

后端 未结 11 2079
面向向阳花
面向向阳花 2020-12-22 18:20

I know you can do mkdir to create a directory and touch to create a file, but is there no way to do both operations in one go?

i.e. if I wa

11条回答
  •  盖世英雄少女心
    2020-12-22 19:02

    In the special (but not uncommon) case where you are trying to recreate the same directory hierarchy, cp --parents can be useful.

    For example if /my/long contains the source files, and my/other already exists, you can do this:

    cd /my/long
    cp --parents path/here/thing.txt /my/other
    

提交回复
热议问题