MV, CP command for Linux

Source: Internet
Author: User

using the MV command
1. Role
MV command to rename a file or directory or to move a file from one directory to another. This command is equivalent to the combination of the Ren and move commands under the DOS system. Its use rights are for all users.
2. Format
mv [options] source file or directory destination file or directory
3.[options] Main parameters
-I: Interactive mode operation. If the MV operation will result in overwriting an existing target file, then the system asks whether to overwrite it, asking the user to answer "y" or "n", which avoids overwriting the file by mistake.
-F: Disables interactive operation. MV operation to overwrite an existing target file without giving any indication, after specifying this parameter the I parameter will no longer work.
4. A second parameter
when the second parameter type is a file, the MV command completes the file rename, which renames the given source file or directory to the specified destination file name.
when the second parameter is a directory name that already exists, the source file or directory parameter can have more than one, and the MV command moves the source files specified by each parameter to the destination directory. When you move a file across a file system, the MV copies the original file, and the link to the file is lost.
5. Application Examples
(1) Move all files in the/usr/udt to the current directory (".") Representation) in:
$ mv/usr/udt/*.
(2) Rename the file Test.txt to Wbk.txt:
$ mv Test.txt wbk.txt

(3) moving files in one subdirectory of the current directory to another subdirectory

MV File name/* Another directory

(4) Move all files under the current folder to the top level directory

MV *.. /
the CP command is used for replication. 
The CP (copy) copies the file or directory.
CP Parameters:
-A or –archive the effect of this parameter with the same as specifying the "-DPR" parameter.
- B or –backup Delete, overwriting the backup of the target file before the backup file is added with a backup string at the end of the word.
- D or –no-dereference When a symbolic connection is copied, the destination file or directory is also established as a symbolic connection and points to the original file or directory connected to the source file or directory.
-F or –force forcibly copies a file or directory regardless of whether the destination file or directory already exists.
-I or –interactive overwrite existing files before asking the user first.
-L or –link to make a hard connection to the source file instead of copying the file.
-P or –preserve preserves the properties of the source file or directory.
-P or –parents retains the path to the source file or directory.
- R recursive processing, the files under the specified directory and subdirectories are processed together.
- R or –recursive recursively handles all files in the specified directory with subdirectories.
-S or –symbolic-link to create a symbolic connection to the source file instead of copying the file.
-s< Backup Tail string > or –suffix=< backup string > After backing up the destination file with the "-B" parameter, a backup string is added to the end of the backup file, and the default back-end string is the symbol "~".
- U or –update Use this parameter to copy a file only if the source file is changed at a later time than the target file is updated or if the name corresponds to the target file that does not exist.
-V or –verbose shows the instruction execution process.
-v< Backup method > or –version-control=< backup method > After backing up the target file with the "-B" parameter, the tail of the backup file is added with a backup string that can be changed not only with "-S" parameter when using "-V" parameter specifies a different backup method, a different tail of the backup string is also generated.
The file system in which the file or directory is copied by-X or –one-file-system must be the same as the file system where the CP instruction is executed, otherwise it will not be copied.
Help online Help.
–sparse=< Use time > Set the time to save sparse files.
–version Displays version information.

MV, CP command for Linux

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.