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’
    
  • 相关阅读:
    js正则表达式 (.+)与(.+?)
    javaScript中的继承
    理解javascript中event loop,
    vue3-provide/inject 注入
    javaScript设计模式
    javaScript语言精粹--函数
    vue在数据data里面引入图片语法是require("")
    查看分支
    vue项目里面预览下载附件
    小程序组件中传值的几种方式
  • 原文地址:https://www.cnblogs.com/yangtao416/p/14451858.html
Copyright © 2011-2022 走看看