The method of using the mv command to move files to the specified directory under linux: Execute the [mv source destination] command. The source can be one or more files or directories, and the target can be a single file or directory.
Environment:
centos6 operating system
The mv command (short for move) is used to move files and directories Rename and move from one location to another.
(Video tutorial recommendation: linux video tutorial)
The syntax of the mv command is as follows:
mv [OPTIONS ] source destination
The source can be one or more files or directories, and the destination can be a single file or directory.
If multiple files or directories are specified as sources, the destination must be a directory. In this case, the source files will be moved to the target directory.
If a single file is specified as the source, and the destination target is an existing directory, the file is moved to the specified directory.
If you specify a single file as the source and a single file as the target, then you are renaming the file.
If the source is a directory and the target is not, the source is renamed to the target, otherwise it is moved into the target directory.
To move a file or directory, you need write permission on both the source and destination. Otherwise, you will get a permission denied error.
Example:
To move the file linuxidc.com.txt from the current working directory to the /tmp directory, you need to run:
mv linuxidc.com.txt /tmp
To rename the file linuxidc.txt, please specify the target file name (here is linuxidc.com.txt):
mv linuxidc.txt linuxidc.com.txt