Concise linux command line notes: MV

Source: Internet
Author: User

MV [options] existing-file new-filename

MV [options] existing-file-list directory

MV [options] existing-directory new-directory

Parameters

The first form:existing-file is the file path that needs to be renamed; New-filename is a new pathname to the file that is used to rename or overwrite

The second form:Existing-file is a list of file paths that need to be moved; directory is the new directory to which files need to be moved to move

The third form:existing-file is the directory path that needs to be renamed; New-directory is the new pathname of the directory that is used to rename or overwrite

Options

-B If the same file name already exists, make a backup before overwriting

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

-I prompts the user for confirmation before overwriting if the same file name already exists

-U compares the original file with the target file modification time and does not overwrite if the target file is newer

-V lists all files that were moved or renamed

ExampleMV
MVlsdemo2.txt 

Renaming files

mv-i
LSdemo2.txt  mv Demo2.txt-MV: Do you want to overwrite "demo.txt"? Y     

Confirmation of pre-existing file overwrite, string representation at the beginning of Y or Y, and any remaining characters representing negation

MV does not have write access to the file name
$LS-L Total Dosage0-rw-r--r--1 root root 8 13:31 cc-rw-r--r--1 Siu siu 8 13:24 dd$ mv DD ccMV: whether to overwrite  "cclscc        

Everyone and group in CC here is root, and my current user is SIU, and will ask for confirmation when overwriting

mv-f file name that does not have write permission
LS-0  January  : Thefollowing:mv BB-lsaa    

Same as above, except that the-f option is added here, and is enforced without prompting when overridden

MV Mobile Directory
LSABC  MVlsabc$ cd abc/lscde     

The CDE directory is moved to the ABC directory here

MV Rename Directory
lsdirlsdir  

Rename the ABC directory here to the DIR directory, MV ABC. /can move ABC to parent directory, flexible here

Mv-u
LS-0  January  : All:mv time1.txt-lstime1.txt time2.txt 

Confirm the modification time to determine whether to overwrite, here Time2.txt modification time is newer than time1.txt, so overwrite failed

mv-v
MV Time1.txt-"time1.txt"time2.txt"lstime2.txt      

List information when moving or overwriting

Mv-b
MV-lsbb.txt  bb.txt~ 

When you make a backup, you back up a file with a ~

Tips

1. In Linux, the concept of overwrite and renaming is almost the same, without the so-called rename in Windows

2. Options you can write in any position, can mv Aa-v BB, can also mv-v AA BB, also can MV AA bb-v

Concise linux command line notes: 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.