- 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$
推薦閱讀
- Python程序設計教程(第2版)
- Python科學計算(第2版)
- OpenShift開發指南(原書第2版)
- Mastering OpenCV Android Application Programming
- Building Mobile Applications Using Kendo UI Mobile and ASP.NET Web API
- 微信小程序全棧開發技術與實戰(微課版)
- 響應式Web設計:HTML5和CSS3實戰(第2版)
- Python程序員面試算法寶典
- HTML 5與CSS 3權威指南(第4版·上冊)
- Visual FoxPro程序設計教程(第3版)
- Python量化交易實戰:使用vn.py構建交易系統
- 軟件工程實用教程
- 中文版AutoCAD 2017實用教程
- SFML Game Development By Example
- Troubleshooting NetScaler