Simple Linux Command Line notes: CP

Source: Internet
Author: User
ArticleDirectory
    • Parameters
    • Option
    • Example
    • Tips

Copy a file

CP [Options]Source-file destination-File

CP [Options]Source-file-list destination-directory

 

Parameters

Method 1:Source-File YesCPThe path name of the file to be copied;Destination-FileYesCPPath Name of the generated copy file

Method 2:Source-file-listYesCPList of file path names to be copied;Destination-FileYesCPDirectory path name of the generated copy

 

Option

-B. If the target file already exists, back up the target file before overwriting.

-I if the target file already exists, a prompt will be prompted during overwriting.

-F forcibly overwrite the target file, regardless of your specific permissions and prompts

-P retains the user, group, permission, modification time, and other information in the original file for copying.

-U: Compare the modification time of the original and existing target files with the same name. If the modification time of the target file is newer, the modification time is not overwritten.

-R or-r recursively copy directory layers and files

-V: displays the name of each file copied by CP.

 

Example CP Current Directory
 
$LsA.txt $CPA.txt B .txt $LsA.txt B .txt

Copy a.txt to B .txt in the current directory.

 

CP-IV Current Directory
$LsA.txt B .txt $CP-IV a.txt B .txtCP: Overwrite?"B .txt"? Y"A.txt"->"B .txt"

Copy in the current directory. If the file already exists, check whether it is overwritten and display the copy information.

 

CP multiple file directories
$CPA.txt B .txt c.txt ABC/$LsABC a.txt B .txt c.txt $LsABC/A.txt B .txt c.txt

Copy multiple files to a directory. Copy a.txt B .txt c.txt to the ABC folder in the same directory.

 

CP-R
 
$CP-R ABCDir/$LsABC a.txt B .txt c.txtDir$Ls DirA.txt B .txt c.txt

Recursively copy the entire directory, including the directory structure and file

 

Tips

The CP option also involves copying linked files, which are not listed here, and I am not rewriting the manual

 

Related Article

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.