Linux Delete copy move file RM,MV,CP command

Source: Internet
Author: User

First look at the example

Delete Copy move File command

Linux Code

Rm-rf/file

-r: Recursive processing parameters
-F: Force all files to be deleted

Linux Code

Cp/test1/file1/test3/file2

Copy the file1 to the test3 and rename it file2

Linux Code

CP-A Test Test1

Copy all subdirectories under the test directory to Test1

Linux Code

Mv/test1/file1/test2/test2

Move File1 to Test2 and rename it test2

CP command

The command D function key will give the D file or directory copy to another file or directory, the same as msdos under the dcopy command, the function is very powerful.

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

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

The command d options have the following meanings:

-A This option is usually used when copying directories. It retains the link, file attributes, and recursively copies the directory, which is equal to the DPR option D combination.

-D Keep links when copying.

-F Deletes the D target file that already exists without prompting.

-I and F options, in contrast, will be prompted to confirm the user before overwriting the target file. When you answer y, the target file will be overwritten with the key interactive copy.

-P In addition to copying source D content, the CP will also copy the modification time and access rights to the new file.

-R If given a directory file of the D source file key, the CP will recursively replicate all D subdirectories and files in the directory. The destination file must be a directory name at this time.

-L do not copy, only key link file.

MV Command

Feature Description: Move or rename an existing file or directory.

Syntax: MV [-bfiuv][--help][--version][-s < Append >][-v < method >][source file or directory [destination file or directory]

Supplemental Note: MV can move files or directories, or change the name of a file or directory.

Parameters
-B or--backup overwrite the file before overwriting.
-F or--force if the destination file or directory is duplicated with an existing file or directory, overwrite the existing file or directory directly.
Ask the user first before overwriting-I or--interactive.
-s< additional word tail > or
--suffix=< additional word tail > is used with the-b parameter to specify the end of the word to be appended to the backup file.
-U or--update when you move or change a file name, the destination file is not overwritten if the destination file already exists and its file date is newer than the source file.
The-V or--verbose displays detailed information when executed.
-v=< method > or
Use the--version-control=< method > with the-b parameter to specify the method of the backup.
--help display Help.
--version Displays version information.

Name: RM

Use Rights: All users
: RM [Options] name ...
Description: Delete files and directories.
Parameters:?
-I check to ask for confirmation before deleting.
-F, even if the original file attribute is set to read-only, is deleted directly, without confirmation.
-R Deletes the directory and the file below.
Example:
Delete all C language files, and ask each confirmation before deleting:
Rm-i *.c
Deletes all files in the finished subdirectory and subdirectories:
Rm-r finished
Feature Description: Deletes a file or directory.
Syntax: RM [-dfirv][--help][--version][file or directory ...]
Supplemental Note: Perform RM directives to delete files or directories, and if you want to delete the directory you must add the parameter "-r", otherwise the preset will only delete the file.
Parameter:
-D or--directory deletes the hard connection data of the directory to be deleted directly to 0, deleting the directory.
-F or--force forcibly deletes a file or directory.
-I or--interactive ask the user before deleting the existing file or directory.
-R or-R or--recursive recursively handles all files and subdirectories in the specified directory.
-V or--verbose displays the instruction execution procedure.
--help online Help. The
--version displays version information.

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.