CP command--file copy
Copy commands for directories and files
CP command syntax and parameters:
CP [OPTION] ... SOURCE ... DIRECTORY
-A |
All |
Equivalent to DPR |
-D |
|
When you copy a symbolic link source file, the destination file also creates the original file of the symbolic link execution source file |
-P |
Preserve |
Preserve file attributes, owner, group, permissions, and time |
-R |
Recursive |
Sub-Files in the recursive directory |
Example:
[Email protected] ~]# ll/etc/services
-rw-r--r--1 root root 362031 2006-02-23/etc/services
[Email protected] ~]# stat/etc/services
File: "/etc/services"
size:362031 blocks:728 IO block:4096 general file
device:fd00h/64768dinode:2282597 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
access:2014-11-11 11:20:33.000000000 +0800
modify:2006-02-23 21:09:23.000000000 +0800
Change:2014-10-21 15:21:26.000000000 +0800
[Email protected] ~]# cp-a/etc/services/tmp/services
[Email protected] ~]# ll/tmp/services
-rw-r--r--1 root root 362031 2006-02-23/tmp/services
[Email protected] ~]# stat/tmp/services
File: "/tmp/services"
size:362031 blocks:728 IO block:4096 general file
device:fd00h/64768dinode:1434761 links:1
Access: (0644/-rw-r--r--) Uid: (0/root) Gid: (0/root)
access:2014-11-11 11:20:33.000000000 +0800
modify:2006-02-23 21:09:23.000000000 +0800
change:2014-11-11 11:44:39.000000000 +0800
Description: All properties and permissions for the file have been copied, and CTime has changed
Extension: The source file is copied to the destination directory where the hint file already exists, how to overwrite the target file directly? And let the system not prompt to overwrite it?
[Email protected] ~]# cp-a/etc/services/tmp/
CP: Do you want to overwrite "/tmp/services"?
In scripts, it is not possible to manually participate in the interaction, the workaround:
[Email protected] ~]# \cp-a/etc/services/tmp/services
[Email protected] ~]# Unalias CP
[Email protected] ~]# cp-a/etc/services/tmp/
[Email protected] ~]#/bin/cp-a/etc/services/tmp/services
Description: By default, cp= Cp-i but the-i parameter is the meaning of the hint overlay
This article is from the Linux Operations sharing blog, so be sure to keep this source http://liangey.blog.51cto.com/9097868/1575258
The CP command in Linux