Linux 常用命令六 cp和mv

 2023-09-10 阅读 21 评论 0

摘要:一、cp命令 Linux中的复制命令。 复制文件: wang@wang:~/workpalce/python$ tree . ├── 1.txt ├── dir └── module2 directories, 1 file wang@wang:~/workpalce/python$ cp 1.txt module/ wang@wang:~/workpalce/python$ tree . ├── 1.txt ├

一、cp命令

Linux中的复制命令。

复制文件:

wang@wang:~/workpalce/python$ tree
.
├── 1.txt
├── dir
└── module2 directories, 1 file
wang@wang:~/workpalce/python$ cp 1.txt module/
wang@wang:~/workpalce/python$ tree
.
├── 1.txt
├── dir
└── module└── 1.txt2 directories, 2 files

Linux命令集、复制目录:

wang@wang:~/workpalce/python$ tree
.
├── 1.txt
├── dir
└── module└── 1.txt2 directories, 2 files
wang@wang:~/workpalce/python$ cp module/ dir/ -r
wang@wang:~/workpalce/python$ tree
.
├── 1.txt
├── dir
│   └── module
│       └── 1.txt
└── module└── 1.txt3 directories, 3 files

二、mv命令

mv命令可以作为Linux中的剪切命令,也可以给文件或者文件夹重命名。

剪切文件:

wang@wang:~/workpalce/python$ tree
.
├── 1.txt
├── dir
└── module2 directories, 1 file
wang@wang:~/workpalce/python$ mv 1.txt module/
wang@wang:~/workpalce/python$ tree
.
├── dir
└── module└── 1.txt2 directories, 1 file

cp命令的用法、剪切文件夹:

wang@wang:~/workpalce/python$ tree
.
├── dir
└── module└── 1.txt2 directories, 1 file
wang@wang:~/workpalce/python$ mv module/ dir/
wang@wang:~/workpalce/python$ tree
.
└── dir└── module└── 1.txt2 directories, 1 file

文件重命名:

wang@wang:~/workpalce/python$ tree
.
├── 1.txt
└── module1 directory, 1 file
wang@wang:~/workpalce/python$ mv 1.txt 2.txt
wang@wang:~/workpalce/python$ tree
.
├── 2.txt
└── module1 directory, 1 file

文件夹重命名:

wang@wang:~/workpalce/python$ tree
.
├── 2.txt
└── module1 directory, 1 file
wang@wang:~/workpalce/python$ mv module/ dir
wang@wang:~/workpalce/python$ tree
.
├── 2.txt
└── dir1 directory, 1 file

三、注意

mv比cp哪个快?cp文件夹时需要-r参数,mv文件夹时不需要-r参数。

 

转载于:https://www.cnblogs.com/gundan/p/8056669.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/4/36999.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息