Linux mv command: moving files or directories

  
 The mv command is used to implement the movement of a file or directory. The mv command format is as follows: mv [options] source file or directory target file or directory The available options have the following meanings. -f: Do not give any indication if the operation wants to overwrite an existing target file. -i: An interactive operation that asks the user whether to overwrite an existing target file if it is overwritten. The obvious difference between the mv and cp commands is that the mv command moves files, the number of files does not increase; the cp command copies files, and the number of files increases. The mv command can also rename the file or directory. The corresponding relationship between the parameter settings and the running result is shown in Table 6.19. Mv parameter setting and running result

command format
running result
mv file name file name change source file name to target file name mv file name directory name move file to target directory mv directory Name directory name target directory already exists, move the source directory to the target directory; rename the mv directory name file name if the target directory does not exist


For example, rename the m1.c file to m2.c, command Behavior: $ mv m1.c m2.c


If you move all the files and directories under /usr/student to the current directory, the command behavior is: $ mv /usr/student/* .

Copyright © Windows knowledge All Rights Reserved