Copy files from one directory into an existing directory

前端 未结 7 1129
野趣味
野趣味 2020-12-07 08:11

In bash I need to do this:

  1. take all files in a directory

  2. copy them into an existing directory

How do I do this? I tried

相关标签:
7条回答
  • 2020-12-07 08:33

    Assuming t1 is the folder with files in it, and t2 is the empty directory. What you want is something like this:

    sudo cp -R t1/* t2/
    

    Bear in mind, for the first example, t1 and t2 have to be the full paths, or relative paths (based on where you are). If you want, you can navigate to the empty folder (t2) and do this:

    sudo cp -R t1/* ./
    

    Or you can navigate to the folder with files (t1) and do this:

    sudo cp -R ./* t2/
    

    Note: The * sign (or wildcard) stands for all files and folders. The -R flag means recursively (everything inside everything).

    0 讨论(0)
提交回复
热议问题