一、cp命令
Linux中的复制命令。
复制文件:
wang@wang:~/workpalce/python$ tree
.
├── .txt
├── dir
└── module directories, file
wang@wang:~/workpalce/python$ cp .txt module/
wang@wang:~/workpalce/python$ tree
.
├── .txt
├── dir
└── module
└── .txt directories, files
复制目录:
wang@wang:~/workpalce/python$ tree
.
├── .txt
├── dir
└── module
└── .txt directories, files
wang@wang:~/workpalce/python$ cp module/ dir/ -r
wang@wang:~/workpalce/python$ tree
.
├── .txt
├── dir
│ └── module
│ └── .txt
└── module
└── .txt directories, files
二、mv命令
mv命令可以作为Linux中的剪切命令,也可以给文件或者文件夹重命名。
剪切文件:
wang@wang:~/workpalce/python$ tree
.
├── .txt
├── dir
└── module directories, file
wang@wang:~/workpalce/python$ mv .txt module/
wang@wang:~/workpalce/python$ tree
.
├── dir
└── module
└── .txt directories, file
剪切文件夹:
wang@wang:~/workpalce/python$ tree
.
├── dir
└── module
└── .txt directories, file
wang@wang:~/workpalce/python$ mv module/ dir/
wang@wang:~/workpalce/python$ tree
.
└── dir
└── module
└── .txt directories, file
文件重命名:
wang@wang:~/workpalce/python$ tree
.
├── .txt
└── module directory, file
wang@wang:~/workpalce/python$ mv .txt .txt
wang@wang:~/workpalce/python$ tree
.
├── .txt
└── module directory, file
文件夹重命名:
wang@wang:~/workpalce/python$ tree
.
├── .txt
└── module directory, file
wang@wang:~/workpalce/python$ mv module/ dir
wang@wang:~/workpalce/python$ tree
.
├── .txt
└── dir directory, file
三、注意
cp文件夹时需要-r参数,mv文件夹时不需要-r参数。