- Learn Linux Quickly
- Ahmed AlKabary
- 147字
- 2021-06-11 18:43:48
Copying one directory
You may also want to copy an entire directory; that's also easily accomplished. To demonstrate, create a directory named cities in your home directory, and inside cities, create three files paris, tokyo, and london as follows:
elliot@ubuntu-linux:~$ mkdir cities
elliot@ubuntu-linux:~$ cd cities/
elliot@ubuntu-linux:~/cities$ touch paris tokyo london
elliot@ubuntu-linux:~/cities$ ls
london paris tokyo
Now if you want to copy the cities directory to /tmp, you have to pass the recursive -r option to the cp command as follows:
elliot@ubuntu-linux:~/cities$ cd ..
elliot@ubuntu-linux:~$ cp -r cities /tmp
You will get an error message if you omitted the -r option:
elliot@ubuntu-linux:~$ cp cities /tmp
cp: -r not specified; omitting directory 'cities'
You can verify that the cities directory is copied to /tmp by listing the files in /tmp:
elliot@ubuntu-linux:~$ cd /tmp
elliot@ubuntu-linux:/tmp$ ls
apple.txt banana.txt carrot.txt cats2.txt cats.txt cities
elliot@ubuntu-linux:/tmp$ ls cities
london paris tokyo
推薦閱讀
- 網頁設計與制作教程(HTML+CSS+JavaScript)(第2版)
- AngularJS深度剖析與最佳實踐
- 零基礎學Java(第4版)
- 秒懂設計模式
- Banana Pi Cookbook
- 3D少兒游戲編程(原書第2版)
- Mastering KnockoutJS
- 零基礎學Python網絡爬蟲案例實戰全流程詳解(高級進階篇)
- Building RESTful Python Web Services
- Mastering React
- App Inventor創意趣味編程進階
- Red Hat Enterprise Linux Troubleshooting Guide
- uni-app跨平臺開發與應用從入門到實踐
- Android Development Tools for Eclipse
- C指針原理揭秘:基于底層實現機制