- Learn Linux Quickly
- Ahmed AlKabary
- 169字
- 2021-06-11 18:43:48
Copying one file
Sometimes you need to copy a single file. Luckily this is a simple operation on the command line. I have a file named cats.txt in my home directory:
elliot@ubuntu-linux:~$ cat cats.txt
I love cars!
I love cats!
I love penguins!
elliot@ubuntu-linux:~$
I can use the cp command to make a copy of cats.txt named copycats.txt as follows:
elliot@ubuntu-linux:~$ cp cats.txt copycats.txt
elliot@ubuntu-linux:~$ cat copycats.txt
I love cars!
I love cats!
I love penguins!
elliot@ubuntu-linux:~$
As you can see, the copied file copycats.txt has the same content as the original file cats.txt.
I can also copy the file cats.txt to another directory. For example, I can copy the file cats.txt to /tmp by running the cp cats.txt /tmp command:
elliot@ubuntu-linux:~$ cp cats.txt /tmp
elliot@ubuntu-linux:~$ cd /tmp
elliot@ubuntu-linux:/tmp$ ls
cats.txt
elliot@ubuntu-linux:/tmp$
Notice that the copied file has the same name as the original file. I can also make another copy in /tmp with a different name:
elliot@ubuntu-linux:~$ cp cats.txt /tmp/cats2.txt
elliot@ubuntu-linux:~$ cd /tmp
elliot@ubuntu-linux:/tmp$ ls
cats2.txt cats.txt
elliot@ubuntu-linux:/tmp$
推薦閱讀
- 自己動手寫搜索引擎
- Visual FoxPro程序設(shè)計教程
- Java高并發(fā)核心編程(卷2):多線程、鎖、JMM、JUC、高并發(fā)設(shè)計模式
- 青少年美育趣味課堂:XMind思維導(dǎo)圖制作
- Mastering Google App Engine
- Spring Boot Cookbook
- Raspberry Pi Home Automation with Arduino(Second Edition)
- Windows Embedded CE 6.0程序設(shè)計實戰(zhàn)
- Clojure for Java Developers
- 計算機應(yīng)用技能實訓(xùn)教程
- Java EE項目應(yīng)用開發(fā)
- 虛擬現(xiàn)實建模與編程(SketchUp+OSG開發(fā)技術(shù))
- Java自然語言處理(原書第2版)
- Java程序設(shè)計
- Building Clouds with Windows Azure Pack