1024programmer Linux How to use the mv command to move files to a specified directory under linux-linux operation and maintenance

How to use the mv command to move files to a specified directory under linux-linux operation and maintenance

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

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/how-to-use-the-mv-command-to-move-files-to-a-specified-directory-under-linux-linux-operation-and-maintenance/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索