How to use the mv command to move files to a specified directory in Linux

王林
Release: 2020-11-03 10:00:49
Original
26703 people have browsed it

How to use the mv command to move files to a 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.

How to use the mv command to move files to a specified directory in Linux

Environment:

centos6 operating system

The mv command (short for move) is used to move files and directories from one Location rename and move to another location.

(Video tutorial recommendation: linux video tutorial)

The syntax of the mv command is as follows:

mv [OPTIONS] source destination
Copy after login

The source can be one or more files or directories , the target 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 target destination is an existing directory, moves the file to the specified directory.

If you specify a single file as the source and a single file as the destination, you will rename the file.

If the source is a directory and the target is not, rename the source to the target, otherwise it will be moved to the target directory.

To move a file or directory, you need write permissions on both the source and destination. Otherwise, you will receive 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
Copy after login

To rename the file linuxidc.txt, Please specify the target file name (here is linuxidc.com.txt):

mv linuxidc.txt linuxidc.com.txt
Copy after login

Related recommendations: linux tutorial

The above is the detailed content of How to use the mv command to move files to a specified directory in Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!