User Tools

Site Tools


unix_commands:mv

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
  • source is the file or directory that you want to move or rename.
  • destination is the file or directory where you want to move the source file or directory or the new name of the source file or directory.

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.

unix_commands/mv.txt · Last modified: 2023/01/17 00:23 by admin

CIFNet is a leading hosting solution provider, offering a wide range of services including IP bandwidth, co-location, VMware and KVM hosting.
Host Your Site with CIFNet!