Linux command —-— MV

Source: Internet
Author: User

  1. Command format:

    MV [option] source file or directory destination file or directory

  2. Command function:

    Move a file or directory; rename files and directories

  3. Common options:

    - b If you need to overwrite the file, back up the file that will be overwritten before overwriting

    - F forced Override

    - I. if the directory file or directory exists, it will prompt for overwrite, enter y overwrite, n cancel overwrite

    - u if the directory file or directory exists, it will overwrite if the source file or directory is relatively new

    - T Specifies the target directory for MV, which is suitable for moving multiple files to the same directory at the same time, where the target directory is in front, and the source file or directory is behind

  4. Common examples:

    Example one: Renaming the file file.txt and directory dir to File.log and Dir1 respectively

    command: MV file.txt file.log--file renamed

    mv dir dir1--directory renaming


    Example two: Move the file Test.txt to the directory/usr/

    Command: MV test.txt/usr/

    Example three: Moving files file1, file2, file3 to the/usr/directory

    Command: mv file1 file2 file3/usr/or mv-t/usr/file1 file2 file 3

    Example four: When the target location is the same as the source file name, such as the source file name File1, and to move the file1 under the root, but there is also a file named File1 under the root, forcibly overwrite

    Command: MV -F File1/file1

    Example five: condition and example four, just require the file1 of the directory location to do a simple backup before overwriting

    Command: MV -B file1/file1

    Note: A simple backup made before overwriting, the generated simple backup file name is file~, but the same file can only be backed up once, once again need to overwrite, the simple backup will also be overwritten

This article is from the "Shiyu" blog, make sure to keep this source http://928004321.blog.51cto.com/10707688/1731192

Linux command —-— MV

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.