cp的一些常用的命令
-a |
相当于-dr |
-d |
若为链接文件就复制链接而非文件本身 |
-r |
复制文件夹 |
-i |
询问 |
-u |
比较两文件,若要复制的文件比要被覆盖的文件新才会进行复制 |
-f |
强制 |
-p |
把属性一同复制过去 |
举例
root@DESKTOP-FA1P4IO:~# ls -l --time={atime,ctime} 12.txt #显示源文件信息日期是八月5号
-rwxrw-rw- 1 sys001 root 84 Aug 5 12:59 12.txt
root@DESKTOP-FA1P4IO:~# cp 12.txt test1/12.txt # 复制
root@DESKTOP-FA1P4IO:~# ls -l --time={atime,ctime} 12.txt #源文件的属性修改时间没有变
-rwxrw-rw- 1 sys001 root 84 Aug 5 12:59 12.txt
root@DESKTOP-FA1P4IO:~# ls -l test1/12.txt # 显示复制过去的文件信息,显示八月21号(复制源文件过来的时间)创建
-rwxrw-rw- 1 root root 84 Aug 21 14:39 test1/12.txt
root@DESKTOP-FA1P4IO:~# cp -p 12.txt test1/12.txt # 重新复制,采用-p
root@DESKTOP-FA1P4IO:~# ls -l te