in the in Linux systems, the command used to copy files or directories is CP, which can copy the source files to the target file or complicate multiple source files to the target directory.
command format:CP [ option ] Source Address (file or directory) destination Address (file or directory)
Command options:
-A,--archive equivalent to -dr,--preserve=all
--backup[=control] Create a backup for a target file that already exists
- b similarto-backup, but does not accept parameters
--copy-contents in recursive processing is to copy special file contents
-F,--force If the destination file cannot be opened, remove it and try again ( you do not need to select this if the-n option exists)
-I,--interactive before overwriting (invalid with the previous- n option)
-H Follow the command-line symbolic link in the source file
-L--link link file without copying
-L,--dereference always follow the symbolic link
-N,--no-clobber do not overwrite existing files (invalidates the previous- i option )
-R,-R, recursive copy all items in directory and directory
Command case:
1), copy a single file to the target directory, the file does not exist in the destination directory file
command:cphello.txt one.txt
[email protected] ~]$ CP hello.txt One.txt
[Email protected] ~]$ ls-l
Total Dosage 16
Drwxrwxr-x 2 Balich Balich 4096 8 months 07:44 doucment
-rw-rw-r--1 Balich Balich 8 months of 07:48 hao.txt ...... .....????????????.
-rw-rw-r--1 Balich Balich 8 months 07:44 hello.txt
-rw-rw-r--1 Balich Balich 8 months of 07:48 one.txt .............. target file (*). Destination Files
[Email protected] ~]$
2), the target file exists, will ask whether to overwrite
command:cphello.txt one.txt
[email protected] ~]$ CP hello.txt One.txt
CP: Do you want to overwrite "One.txt"? y ... ... ..... ... ... ... ... ... .... ..... ..... .... ..... ..... ..... ........, ... and ... and .... ...... tip whether to overwrite
[Email protected] ~]$ ls-l
Total Dosage 16
Drwxrwxr-x 2 Balich Balich 4096 8 months 07:44 doucment
-rw-rw-r--1 Balich Balich 8 months 07:48 hao.txt
-rw-rw-r--1 Balich Balich 8 months of 07:44 hello.txt ...... ....... source File
-rw-rw-r--1 Balich Balich 8 months 07:52 one.txt ... the target file, from the time can be seen has been modified
[Email protected] ~]$
3), copy the entire directory
command:cp-r document/tmp
[Email protected] ~]$ cp-r doucment//tmp
[Email protected] ~]$ ls-l/tmp/doucment/
Total Dosage 4
-rw-rw-r--1 Balich Balich 8 months 07:56 hao.txt
[Email protected] ~]$
This article is from the "Eight Miles Bridge" blog, please be sure to keep this source http://baliq.blog.51cto.com/5984262/1689930
The command CP command for the CentOS Linux system