Latest web development tutorials

Linux mv command

Linux command Daquan Linux command Daquan

Linux mv command to rename a file or directory, or the file or directory moved to another location.

grammar

mv [options] source dest
mv [options] source... directory

Parameter Description:

  • -i: If the file name already exists in the specified directory, the first asking to overwrite the old file;
  • -f: When mv operation to cover an existing target file does not give any indication;

mv parameter setting and operating results

Command Format operation result
The file name mv The source file name to the target file name
mv filename directory name Move the file to the target directory
mv directory name directory name Target directory already exists, the source directory to the target directory; renamed the target directory does not exist
mv directory name filename Error

Examples

The renamed file aaa bbb:

mv aaa bbb

The info directory into the logs directory. Note that if the logs directory does not exist, the command info renamed logs.

mv info/ logs 

Again all files and directories in / usr / student moved under the current directory, the command line:

$ mv /usr/student/*  . 

Linux command Daquan Linux command Daquan