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’
    
  • 相关阅读:
    java 调用Python
    RestController 能不能通过配置关闭
    java jdb
    Curator zookeeper
    「ASCII 流程图」工具——Graph Easy
    Python String Formatting Best Practices
    idea java9以及以上 出现找不到class的情况
    时间序列分析 异常分析 stl
    pip install whl
    t-SNE 层次聚类
  • 原文地址:https://www.cnblogs.com/yangtao416/p/14451858.html
Copyright © 2011-2022 走看看