Linux Commands-MV: moving or renaming files

Source: Internet
Author: User

Command format

CP [OPTION] ... [-T] SOURCE DEST

CP [OPTION] ... SOURCE... DIRECTORY

CP [OPTION] ...-t DIRECTORY SOURCE...

Command parameters

--backup[=control]
Create a backup of each existing target file.

-B
Similar to the--backup option, but does not accept parameters.

-F,--force
Do not prompt before overwriting.

-I.,--interactive
Give a hint before overwriting.

-N,--no-clobber
Does not overwrite existing files. If multiple in-I,-F,-n is specified, only the last one takes effect.

-S,--suffix=suffix
Replace the usual backup file suffix.

-T,--target-directory=directory
Moves the source file or directory specified by all parameters to the specified directory.

-T,--no-target-directory
Treat the target directory as a normal file.

-U,--update
When moving files from one directory to another, only those files that do not exist in the destination directory or the corresponding files in the destination directory are moved.

-V,--verbose
An informational message is displayed when the file is moved.

--help
Displays help information.

--version
Displays version information.

Instance

A) Move the file F1 to F2. If F2 exists, it will be overwritten by F1. If F2 does not exist, rename the F1 to F2.

MV F1 F2 [Email protected] cmdline]$ LSF2

b) Move the files F1 and F2 to the directory D1. D1 must already exist.

MV F1 F2 D1 [Email protected] cmdline]$ ls-r.:d 1./d1:f1  F2

c) Move the directory D1 and its contents to the directory D2. If D2 does not exist, it is equivalent to renaming D1 to D2.

[[email protected] cmdline]$ ls-lir.:total 4919434 drwxrwxr-x 2 ucm ucm 4096 Oct  1 14:33 d1./d1:total 49 19433 -rw-rw-r--1 UCM ucm  0 Oct  1 14:32 F1919432 -rw-rw-r--1 ucm ucm Oct  mv D1 D2[ [Email protected] cmdline]$ ls-lir.:total 4919434 drwxrwxr-x 2 ucm ucm 4096 Oct  1 14:33 d2./d2:total 49 19433 -rw-rw-r--1 UCM ucm  0 Oct  1 14:32 F1919432 -rw-rw-r--1 ucm ucm Oct  1 14:32 f2

Linux Commands-MV: moving or renaming files

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.