zoukankan      html  css  js  c++  java
  • Linux 常用命令六 cp和mv

    一、cp命令

    Linux中的复制命令。

    复制文件:

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

    复制目录:

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

    二、mv命令

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

    剪切文件:

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

    剪切文件夹:

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

    文件重命名:

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

    文件夹重命名:

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

    三、注意

    cp文件夹时需要-r参数,mv文件夹时不需要-r参数。

  • 相关阅读:
    2017-5-25 母版页
    2017-5-25 分页加条件查询合体
    2017-5-23 WebForm 中的分页功能和条件查询功能
    2017-5-17 WebForm 基础
    2017-5-14 心情
    2017-5-10 小型人员管理系统
    2017-5-9 打开唯一窗体的实例操作
    2017-5-8 TreeView 实现三级联动 (递归方法)
    2017-5-7 三级联动数据库 数据保存
    2017-5-7 三级联动
  • 原文地址:https://www.cnblogs.com/gundan/p/8056669.html
Copyright © 2011-2022 走看看