Linux command-file management class mv command

Source: Internet
Author: User
Command function: move or rename a file or folder name command syntax: mv [-parameter] [source file or directory or target file or directory] parameter:-B or & ndash; if the backup file needs to be overwritten, the backup is overwritten first. -F OR & ndash; force: if the target file or directory is the same as the existing file or directory, the existing file or directory will be overwritten. -I or & ndash; interactiv

Command function:MobileOrRenameFile or folder name
Command syntax: mv [-parameter] [source file or directory or target file or directory]

Parameters:

  • -B or-backup if you need to overwrite the file, overwrite the original backup.
  • -F or-force: if the target file or directory is the same as the existing file or directory, the existing file or directory will be overwritten.
  • Ask the user before-I or-interactive overwriting.
  • -S <附加字尾> Or
  • -Suffix = <附加字尾> Used with the-B parameter to specify the end of the backup file.
  • -U or-update when moving or changing the file name, if the target file already exists and its file date is newer than the source file, the target file is not overwritten.
  • -V or-verbose displays detailed information during execution.
  • -V = <方法> Or
  • -Version-control = <方法> Used together with the-B parameter, you can specify the backup method.
  • -Help: displays help.
  • -Version: displays the version information.

Example:

  • Move the file to a directory

Mv hello test/hello, command to move the hello file to the test folder

  • Rename a file
    Change file name hello to world

  • Display execution information during execution

  • The following parameter example is related to the application scenario that "if a file is moved to a certain place and a file with the same name exists somewhere", which is mainly about how to deal with overwriting the file. First, create a file "hello" under the "test" file with the content "hello world2", and then move the "hello" file in the current folder to the "test" folder. this creates an application scenario.

    • -B parameter, backup during overwriting
      We can see that the overwritten file hello backs up a file hello ~, Before overwriting, I asked the user

The-f and-I parameters are not introduced because the user is asked by default and the backup is not performed.

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.