The mv command is used to move or rename files and directories in Unix/Linux operating systems. Here are some examples of how to use the mv command:
- To rename a file:
mv oldfile newfile
This will rename the file
oldfiletonewfile. - To move a file to a different directory:
mv file /path/to/directory/
This will move the file
fileto the directory/path/to/directory/. - To move multiple files to a different directory:
mv file1 file2 file3 /path/to/directory/
This will move the files
file1,file2, andfile3to the directory/path/to/directory/. - To move a directory:
mv directory /path/to/directory/
This will move the directory
directoryto the directory/path/to/directory/. - To move and rename a file at the same time:
mv oldfile /path/to/directory/newfile
This will move the file
oldfileto the directory/path/to/directory/and rename it tonewfile. - To move and rename a directory at the same time:
mv olddirectory /path/to/directory/newdirectory
This will move the directory
olddirectoryto the directory/path/to/directory/and rename it tonewdirectory.