zoukankan      html  css  js  c++  java
  • ⑥linux基础命令 cp

    cp 复制 copy

    复制文件 -v显示过程
    [root@rstx-53 test]# touch file.txt
    [root@rstx-53 test]# cp file.txt  /tmp/file_copy
    [root@rstx-53 test]# ll /tmp/file_copy 
    -rw-r--r-- 1 root root 0 Feb 26 13:19 /tmp/file_copy
    [root@rstx-53 test]# cp file.txt  /tmp/file_copy1 -v
    ‘file.txt’ -> ‘/tmp/file_copy1’
    
    复制过程中不改变属主属组
    [root@rstx-53 test]# ll
    -rw-r--r-- 1 root root 0 Feb 26 13:19 file.txt
    [root@rstx-53 test]# chown yangtao.yangtao file.txt 
    [root@rstx-53 test]# ll
    -rw-r--r-- 1 yangtao yangtao 0 Feb 26 13:19 file.txt
    [root@rstx-53 test]# cp file.txt  /tmp/file.txt
    [root@rstx-53 test]# ll /tmp/file.txt 
    -rw-r--r-- 1 root root 0 Feb 26 13:23 /tmp/file.txt
    
    [root@rstx-53 test]# ll /tmp/file.txt 
    -rw-r--r-- 1 root root 0 Feb 26 13:23 /tmp/file.txt
    [root@rstx-53 test]# cp file.txt  /tmp/file.txt -p
    cp: overwrite ‘/tmp/file.txt’? y
    [root@rstx-53 test]# ll /tmp/file.txt 
    -rw-r--r-- 1 yangtao yangtao 0 Feb 26 13:19 /tmp/file.txt
    
    复制目录 -r 递归复制目录
    [root@rstx-53 test]# cp /etc/ /tmp/
    cp: omitting directory ‘/etc/’
    [root@rstx-53 test]# cp /etc/ /tmp/ -r
    [root@rstx-53 test]# ll /tmp/etc/
    
    跳出交互式复制目录文件 alias cp -i
    [root@rstx-53 test]# cp /etc/ /tmp/ -rf
    cp: overwrite ‘/tmp/etc/fstab’? ^C
    [root@rstx-53 test]# ^C
    [root@rstx-53 test]# cp /etc/ /tmp/ -r
    
    cp 备份文件
    [root@rstx-53 test]# cp -v /etc/{hosts,hosts.bak}
    ‘/etc/hosts’ -> ‘/etc/hosts.bak’
    
    [root@rstx-53 test]# cp -v /etc/hosts{,-bak}
    ‘/etc/hosts’ -> ‘/etc/hosts-bak’
    
    反转 -t
    [root@rstx-53 test]# cp -vt /tmp/  /etc/hosts
    ‘/etc/hosts’ -> ‘/tmp/hosts’
    
  • 相关阅读:
    异常处理基本语法
    数字取舍(trunc round ceil floor)
    关于union的理解
    SQL Loader 导入EXCEL 数据到ORACLE 数据库
    临时表的使用方法
    对外投资
    存货盘盈盘亏核算
    现金流量表补充资料的编制公式
    会计科目的具体定义
    中英文职位对照之 会计与财务
  • 原文地址:https://www.cnblogs.com/yangtao416/p/14451858.html
Copyright © 2011-2022 走看看