renyanping 发表于 2018-5-23 12:15:02

Linux cp命令用法

  

  # ls -al
  total 16
  drwxr-xr-x.4 root    root    4096 Oct 11 11:41 .
  drwxrwxr-x. 22 bluesun bluesun 4096 Oct 11 11:41 ..
  -rw-r--r--.1 root    root       0 Oct 11 11:41 1
  drwxr-xr-x.4 root    root    4096 Oct 11 11:00 jsp
  drwxr-xr-x.3 root    root    4096 Oct 11 11:00 WEB-INF
  # pwd
  /root/20141011ntlib
  
  test是空文件夹
  root@soon test]# pwd
  /root/test
  
  cp -r 20141011ntlib/ test/
  
  # ls -al
  total 12
  drwxr-xr-x.3 root    root    4096 Oct 11 11:45 .
  drwxrwxr-x. 22 bluesun bluesun 4096 Oct 11 11:41 ..
  drwxr-xr-x.4 root    root    4096 Oct 11 11:45 20141011ntlib
  
  # cp -r 20141011ntlib/. test
  # cd test
  # ls -al
  total 16
  drwxr-xr-x.4 root    root    4096 Oct 11 11:54 .
  drwxrwxr-x. 22 bluesun bluesun 4096 Oct 11 11:41 ..
  -rw-r--r--.1 root    root       0 Oct 11 11:54 1
  drwxr-xr-x.4 root    root    4096 Oct 11 11:54 jsp
  drwxr-xr-x.3 root    root    4096 Oct 11 11:54 WEB-INF
  
  文件变动后,需要覆盖至test目录
  # ls -lR
  .:
  total 4
  -rw-r--r--. 1 root root    0 Oct 11 11:58 2
  -rw-r--r--. 1 root root    0 Oct 11 11:58 3
  drwxr-xr-x. 2 root root 4096 Oct 11 11:59 jsp
  
  ./jsp:
  total 0
  -rw-r--r--. 1 root root 0 Oct 11 11:59 abcdef.jsp
  
  # cp -R 20141011ntlib/. test
  
  # ls -lR test
  test:
  total 8
  -rw-r--r--. 1 root root    0 Oct 11 12:02 1
  -rw-r--r--. 1 root root    0 Oct 11 12:03 2
  -rw-r--r--. 1 root root    0 Oct 11 12:03 3
  drwxr-xr-x. 4 root root 4096 Oct 11 12:03 jsp
  drwxr-xr-x. 3 root root 4096 Oct 11 12:02 WEB-INF
  
  test/jsp:
  total 16
  -rw-r--r--. 1 root root    0 Oct 11 12:03 abcdef.jsp
  drwxr-xr-x. 2 root root 4096 Oct 11 12:02 bookCatalogue
  -rw-r--r--. 1 root root 7290 Oct 11 12:02 index.jsp
  drwxr-xr-x. 2 root root 4096 Oct 11 12:02 web
  
  # rm -rf *
  
  
页: [1]
查看完整版本: Linux cp命令用法