Click the blue text to follow us

1. Introduction
The mv command (full English name: move) is used to move specified files or directories to other directories, or to rename specified files and directories.
2. Syntax
Syntax: mv [options]… source_file target_file
or mv [options]… source_file… directory
Parameter Description:
|
Option |
Description |
|
-f |
Forcefully overwrite the target file without asking |
|
-i |
Prompt the user for confirmation before overwriting the target file |
|
-b |
Create a backup of the target file before overwriting |
|
-v |
Display detailed information about the execution process |
|
-n |
Do not overwrite existing files |
|
-u |
Only overwrite if the source file is newer than the target file |
|
–help |
Display help information |
|
–version |
Display version information |
3. Practical Examples
1. Rename file a to b
[root@app01 soft]# touch a
[root@app01 soft]# ls
[root@app01 soft]# mv a b
[root@app01 soft]# ls
2. Move file b to the /app directory
[root@app01 soft]# ls -lrt /app/
ls: cannot access '/app/b': No such file or directory
[root@app01 soft]# mv b /app
[root@app01 soft]# ls -lrt /app/b
-rw-r--r-- 1 root root 0 Jul 26 19:29 /app/b
3. Move directory abc to the /app directory
[root@app01 soft]# ls -d /app/abc
ls: cannot access '/app/abc': No such file or directory
[root@app01 soft]# mv abc /app
[root@app01 soft]# ls -d /app/abc
/app/abc
4. Rename directory abc to abcd
[root@app01 soft]# ls
abc
[root@app01 soft]# mv abc abcd
[root@app01 soft]# ls
abcd
5. Move a specified directory to the /app directory and rename it
[root@app01 soft]# ls -d /app/test
ls: cannot access '/app/test': No such file or directory
[root@app01 soft]# mv abcd /app/test
[root@app01 soft]# ls -d /app/test
/app/test
6. Move all files from the /soft directory to the /app directory, overwriting existing files if they exist
[root@app01 soft]# mv -f /app/soft/* /app
Long press the QR code to follow us


CSDN BlogδΈ¨Countless Stars in the Sky
https://blog.csdn.net/myself88129