Instruction name: CP (copy)
Features: Copy a file to another file or copy several files to another directory.
Syntax format:
CP [Options] Source Dest
CP [options] source ... directory
Common parameter Description:
-A as far as possible file status, permissions and other information are reproduced as original.
-R If the source contains a directory name, the files under the directory are also copied to the destination.
-F If a destination already has a file with the same file name, it should be deleted before copying.
Instruction Usage Example:
1. Copy the file AAA (already present) and name the BBB:
CP AAA BBB
2. Copy all C-language programs to the finished subdirectory:
CP *.c finished
3. Copy files from the specified directory to the current directory and rename
[email protected] root]# CP ~/.BASHRC Bashrc_bak
4. Force copying files from the specified directory to the current directory, regardless of whether the current directory contains the file
[Email protected] root]# cp-f ~/.BASHRC BASHRC
5. Copy the specified directory to the current directory
[Email protected] root]# cp-r/root/test.
[Email protected] root]# cp-r/root/test/.
As a result, when you copy a directory, the last level of the source path is copied all over, including itself.
6. Copy files from the specified directory to the specified directory
[email protected] root]# CP ~/.BASHRC/BAK/.BASHRC
7. Copy all the properties of the source file as you copy it. If you do not specify a parameter, the destination file may be inconsistent with the source file properties.
[Email protected] root]# cp-a ~/.BASHRC/BAK/.BASHRC
8. If two folders to ensure synchronization, one file changed, another file is changed, but to ensure that two files are up to date.
[Email protected] root]# cp-u/SRC/.BASHRC/BAK_SRC/BASHRC
Linux CP operation, learn a little every day