The mv command in Linux and Unix-like systems stands for “move.” It is used to move or rename files or directories.
Here is the basic syntax for the mv command:
mv [options] source destination
Here are some examples of the mv command in action:
1. To move a file called “file1.txt” from the current directory to a directory called “backup”:
$ mv file1.txt backup/
2. To rename a file called “file1.txt” to “file2.txt” in the current directory:
$ mv file1.txt file2.txt
3. To move a directory called “directory1” to a directory called “backup”:
$ mv directory1 backup/
4. To move multiple files and directories (directory1, in this example) at once
$ mv file1.txt file2.txt directory1 backup/
5. To force overwrite the destination file if it already exist
$ mv -f file1.txt backup/
Note: The -f option is used to force overwrite the destination file.
In all the above examples, mv command is used to move or rename the files or directories from source to destination. It can also be used to rename files or directories within the same location by specifying the new name as the destination.
Warning: Please be careful when using mv command as it can overwrite files or directories that are in the destination location.