File management commands for Linux commands CP, MV, RM

Source: Internet
Author: User

File management commands for Linux commands CP, MV, RM


CP, copy command: Copying files or directories

Grammar:

CP [OPTION] ... [-T] SOURCE DEST

CP [OPTION] ... SOURCE ... DIRECTORY

CP [OPTION] ...-t DIRECTORY SOURCE ...

CP SRC DEST:

SRC is a file:

If Dest does not exist: Creates a new target file and copies the SRC to the target file;

if dest exists:

If Dest is a file: Use src content to overwrite the dest file;

If Dest is a directory: a new file with the same name as the original file in the Dest directory, copy the SRC content


To the newly created target file with the same name;


CP SRC ... DEST:

If Dest does not exist:

is wrong;

if dest exists:

If Dest is a file: error;

If Dest is a directory:


Common parameter options:

-R,-r: Recursive replication;

-D: Do not track symbolic links;

--preserve[=attr_list]:mode, ownership, Timestamps,context, links, xattr, all

-A:-dr--preseve=all the effect of this parameter with the same as specifying the "-DPR" parameter

-i:interactive Ask the user before overwriting the file

-f:force forcibly copying a file or directory, regardless of whether the destination file or directory already exists

-V: Display procedure

Example:

#cp-I file1 file2//interactively copy the file file1 to a file file2

#cp-F file1 file2//Copy the file File1 to File2 because the destination file already exists, so specify to use


Mode of forced replication


MV, move command: Move files or rename files, often used to back up files or directories

Grammar:

MV [OPTION] ... [-T] SOURCE DEST

MV [OPTION] ... SOURCE ... DIRECTORY

MV [OPTION] ...-t DIRECTORY SOURCE ...


Common parameter options:

-I: If the target file (destination) already exists, you will be asked to overwrite

-f:force mandatory Meaning, if the target file already exists, will not ask and directly overwrite

Example:

#mv test.log test1.txt//file renamed


RM, remove command: Delete one or more files or directories in a directory

Syntax: RM [OPTION] ... FILE ...

Common parameter options:

-f:--force Ignore non-existent files, never give hints

-i:--interactive for interactive deletion

-R,-r:--recursive instructs RM to recursively delete all directories and subdirectories listed in the parameter

Example:

# RM log.log//Delete Enquiry

RM: Do you want to delete the generic file "Log.log"? Y

# RM-RF Log1.log//forced Delete and recursive


This article is from the "10,000-hour Law" blog, be sure to keep this source http://daisywei.blog.51cto.com/7837970/1687832

File management commands for Linux commands CP, MV, RM

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.