Linux Replication folder and file instance introduction

Source: Internet
Author: User

CP command
Format: CP [option] source file or directory destination file or directory
Option Description:-B with the same name, to prepare the original file
-F Force overwrite file with same name
-R to keep the original directory structure in a recursive way copy files

Cp-r/tmp/a/root/a

Cases

Copying files, copying files only if the source file is newer than the destination file's modification time
Cp-u-V file1 file2

. copy file file1 to file File2
CP file1 File2

. interactively copy file file1 into a file file2
Cp-i file1 file2

Copy the file file1 to File2 because the destination file already exists, so specify the mode to use forced replication
Cp-f file1 file2

. copy directory Dir1 into a directory Dir2
Cp-r file1 file2

. Also copy files File1, file2, File3, and directory Dir1 to Dir2
Cp-r file1 file2 file3 dir1 dir2

. preserve file properties when copying
Cp-p a.txt tmp/

. Preserve the directory structure of files when replicating
Cp-p/var/tmp/a.txt./temp/

. Generate backup files when replicating
Cp-b a.txt tmp/

The backup file is generated when copying, and the tail-label ~1~ format
Cp-b-V T a.txt/tmp

. Specify the tail label of the backup file
Cp-b-S _bak a.txt/tmp


Copying files does not prompt

# VI ~/.BASHRC

If you see something like this, the following commands are executed with an alias, which means that the-I parameter is automatically added

Alias rm= ' Rm-i '
Alias cp= ' Cp-i '
Alias mv= ' Mv-i '

In order to copy and move a large number of files to cover the target, there will be no prompts, the command should write

# cp-rf/home/huzs.net/*/www/huzs.net/

Note that the CP command is added, meaning that it is not allowed to run with the alias in ~/.BASHRC, that is, the-i parameter


CP command

Function: Copy the given file or directory to another file or directory, just like the Copy command under DOS, the function is very powerful.

Syntax: CP [option] source file or directory destination file or directory

Description: This command copies the specified source files to the destination file or copies multiple source files to the destination directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.