Home  >  Article  >  System Tutorial  >  Basic linux commands - detailed explanation of mv

Basic linux commands - detailed explanation of mv

WBOY
WBOYforward
2024-03-14 16:30:03877browse

Basic linux commands - detailed explanation of mv

mv(option)(parameter) Cut, or move and rename in the same directory
1. If the target file is a folder, the source file is moved directly to the folder, and the name is still the name of the source file.
2. If the target file is a file, the name of the source file will also be changed when it is moved
3. If there are multiple source files, the target must be a directory and moved to the directory simultaneously

-b: When the target file exists, backup it first and then overwrite it

[root@bogon admin]# mv -b a/aa b/
mv: overwrite `b/aa'? y
[root@bogon admin]# ls b
aa  aa~  bb

-f: Force overwriting when the target file exists

[root@bogon admin]# mv -f a/aa b/
[root@bogon admin]# ls b
aa   bb

-i: Default option, when the target file exists, prompt whether to overwrite

[root@bogon admin]# mv -i a/aa b/
mv: overwrite `b/aa'? y
[root@bogon admin]# ls b
aa   bb

-t: Specify the target first, then specify the source

[root@bogon admin]# mv -t b/ a/aa
mv: overwrite `b/aa'? y
[root@bogon admin]# ls a b
a:
bb
 
b:
aa    bb

-v: display process

[root@bogon admin]# mv -fv a/aa b/
`a/aa' -> `b/aa'

The above is the detailed content of Basic linux commands - detailed explanation of mv. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete