mv (Move)
Explanation
The mv command is used to move files and directories from one location to another. It is also the standard command for renaming files and directories in Linux.
Basic Syntax
mv [OPTION]... SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
Common Flags and Options
| Flag | Description |
|---|---|
-i, --interactive | Prompt before overwrite. |
-f, --force | Do not prompt before overwriting. |
-v, --verbose | Explain what is being done. |
-n, --no-clobber | Do not overwrite an existing file. |
Real-world Examples
-
Rename a file:
mv oldname.txt newname.txt -
Move a file into a directory:
mv file.txt /path/to/directory/ -
Move multiple files to a directory:
mv file1.txt file2.txt /path/to/directory/