CP Replication
CP source file path Directory file path
[Root@zabbix_agentd ~]# CP./1.sh/tmp/
[Root@zabbix_agentd ~]# CP./1.sh/tmp/2.sh
As shown above, the first CP./1.sh/tmp/, copy the current directory under 1.SH to TMP is still called 1.sh,
Second CP./1.sh/tmp/2.sh, copy the current directory under 1.sh to rename to 2.sh under TMP
View
[Root@zabbix_agentd ~]# cat/tmp/{1.sh,2.sh}
Accepted conn:40730031
Accepted conn:40730031
[Root@zabbix_agentd ~]#
If the directory file exists, you are prompted to overwrite it
Create a new file if the destination file does not exist
If the directory exists and is a directory: Copy to the target directory and keep the original
Of course, the source file can also appear multiple, if the source is multiple, the target must be a directory
[Root@zabbix_agentd ~]# cp 1.sh 1.txt anaconda-ks.cfg/tmp/
Cp:overwrite '/tmp/1.sh '? Y
[Root@zabbix_agentd ~]#
CP Replication Directory-r if the target file exists there will be an error
[Root@zabbix_agentd ~]# cp-r/etc/zabbix/tmp/zabbix123
[Root@zabbix_agentd ~]# ll/tmp/zabbix123
Total 16
Drwxr-xr-x. 2 root root 4096 June 9 20:36 scripts
-rw-r--r--. 1 root root 11145 June 9 20:36 zabbix_agentd.conf
Drwxr-xr-x. 2 root Radix 9 20:36 zabbix_agentd.d
[Root@zabbix_agentd ~]#
* For multiple wildcard characters in bash
? To a single wildcard character
[] matches any single character that knows the range of characters
If you copy only files to a directory, you can do the following.
[Root@zabbix_agentd ~]# cp-r/etc/zabbix/*/tmp/zabbix123/scripts/
Common
[[: Upper:]] All uppercase letters, equivalent to A-Z
[[: Lower:]] all lowercase
[[: Alpha:]] lowercase uppercase is counted
[[: Digit:]]0-9 All numbers
[[: Alnum:]] The number letters all contain
[[: Space:]] whitespace characters
[[: Punct:]] punctuation mark
* For multiple wildcard characters in bash
? To a single wildcard character
[] matches any single character that knows the range of characters
Matches any single character outside the specified range of characters [^]
[^0-9], mismatched numbers, non-numeric characters
Example:
Copy begins with a, with 2 arbitrary characters in the middle, and a file ending with W
Cp-r a?? W
Copy begins with a, any middle character, ending with W
Cp-r AW
Copy any number at the beginning, ending with a number other than a digit
Cp-r [0-9][^0-9]
Copying begins with a non-letter, followed by a character and any length of character
Cp-r [^[:alpha:]][[:alpha:]]*
CP Common options:
-R: Recursive
-I: Interacting
-D: Copy the linked file itself, not the source file you point to
-A: Keep all attributes equal to-DR
-P: Reserved user permissions. Only administrators can retain permissions
-F: Force overwrite