![]() It also means that file_3 won't me moved while as file_2 will be updated. In other words, in the destination directory, the file_2 is older and file_3 is newer than the ones being moved. rw-rw-r- 1 abhishek abhishek 0 Apr 4 10:39 file_3 rw-rw-r- 1 abhishek abhishek 0 Apr 4 10:37 file_2 In the destination directory dir1, file_2 was last modified at 10:37 and file_3 was modified at 10:39. rw-rw-r- 1 abhishek abhishek 0 Apr 4 10:06 file_3 rw-rw-r- 1 abhishek abhishek 0 Apr 4 10:39 file_2 file_2 was modified at 10:39 and file_3 was modified at 10:06. With this, the destination file will only be replaced if the file being moved is newer than it. The mv command comes with some special options. You can press N to deny replacement and Y or Enter to replace the destination file. Ask for confirmation before replacing the files at the destination. Like the cp command, the mv command also has an interactive mode with option -i.Īnd the purpose is the same. If the destination already has files with the same name, the destination files will be replaced immediately. ![]() ![]() Move the files back to the current directory from dir3. Let's continue our example scenario to move multiple files. You can move multiple files to another location in the same mv command: mv file1 file2 fileN destination_directory Now, let's say I want to move the file_1 to dir3. This is the directory structure in the example: tree You should practice along with it by replicating the example scenarios on your system. You can use either the absolute or relative path. The role of path comes to play here as well. Linux has a dedicated mv command (short for move) for moving files and directories to other locations.Īnd using the mv command is quite simple: mv source_file destination_directory Basically, moving files in the command line can be thought same as cut-paste in a graphical environment.
0 Comments
Leave a Reply. |