![]() ![]() mv old-filename /new/path/new-filenameįor example, to move a file named student1.txt to /var/students and rename it to class1-student1.txt, you would run the following command. When mv moves the file, it will be given a new name. You simply give the target path a different name. mv /home/student1/lab-work.log /var/labs/student1/lab-work.log Moving and Renaming files on LinuxĪ file can be renamed during a move process using the mv command. ![]() mv source-file /new/pathįor example, to move a file from /home/student1/lab-work.log to /var/labs/student1/lab-work.log, you would run the following command. To move a file to another location we use the same method as renaming a file, except the file path should be different. Provided the file target is the same directory, all file attributes will remain, including permissions. To rename a file named student1 to student10, for example, you would run the following command. The mv command will take the source file specified and rename it to the target file. ![]() For renaming files, only two arguments are needed, which are the source file and the target file. The command accepts two or more arguments. To rename a file in Linux you use the mv command. This means the operations done on one can be also done on the other, with very few exceptions.Īs such, you will notice that commands used to perform actions on files are identical with directories. In this tutorial, you will learn how to use the mv command to move and renames files and directories on Linux.įiles and directories on Linux as very similar, from a filesystem point of view. ![]()
0 Comments
Leave a Reply. |