Learn Linux Quickly
上QQ阅读APP看书,第一时间看更新

Copying multiple directories

You can also copy multiple directories the same way you copy multiple files; the only difference is that you have to pass the recursive -r option to the cp command.

To demonstrate, create the three directories d1, d2, and d3 in Elliot's home directory:

elliot@ubuntu-linux:~$ mkdir d1 d2 d3

Now you can copy all three directories to /tmp by running the cp -r d1 d2 d3 /tmp command:

elliot@ubuntu-linux:~$ cp -r d1 d2 d3 /tmp
elliot@ubuntu-linux:~$ cd /tmp
elliot@ubuntu-linux:/tmp$ ls
apple.txt banana.txt carrot.txt cats2.txt cats.txt cities d1 d2 d3