Linux Command mv, linuxmv

Source: Internet
Author: User

Linux Command mv, linuxmv

Mv in linux means move.


The general form of this command:

Mv [Option] parameter 1 parameter 2


Option:

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

-F if the same file name already exists and the user does not have the write permission, forcibly Overwrite

-I if the same file name already exists, prompt the user to confirm before Overwriting

-U: Compare the modification time of the original and target files. If the target file is newer, it will not be overwritten.

-V: list all moved or renamed files



Parameters 1 and 2 can be divided into three forms:

1. mv [Option] File 1 file 2 this method is used for file overwrite and rename

2. mv [Option] File 1 directory 2 this method is used to move files to directories

3. mv [Option] Directory 1 directory 2 this method is used for directory overwrite and rename


Example:

For format 1, The test1 file exists in the testdir directory, and the test2 file does not exist.

Rename file 1 to file 2.


For Form 1, testdir directory contains test1 and test2, then test2 is overwritten as test1






For Format 2, The testdir directory contains the test1 file and newdir directory. If the newdir directory is empty, the file will be moved to the directory.


The testdir directory contains the newdir directory in the test1 file box and the test1 file in the newdir directory.

The directory overwrites the new test1 file. If the value of test1 is 1, and the value of test1 in newdir is 2, after the mv test1 newdir

The value of test1 in the newdir directory is 1.





For Form 3, if both command parameters are directories, if parameter 1 is an existing Directory and parameter 2 is an existing Directory, implement directory 1

Rename directory 2. If both directory 1 and directory 2 exist, the directory overwrites.




Reprinted, please note: Xiao Liu


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.