Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use mv command to move files and directories in Linux system

2025-02-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to use the mv command to move files and directories in the Linux system. I think it is very practical, so I share it with you. I hope you can get something after reading this article.

The mv (move) command, which is suitable for moving files or directories, can also rename files or directories.

The syntax format of the mv command is as follows:

[root@bogon ~] # mv [option] Source file destination file

The part enclosed by [] is optional and can be ignored.

The options and functions of the mv command are shown in Table 1.

Option function-f force overwrite, if the target file already exists, do not ask, directly force to overwrite-I interactive movement, if the target file already exists, then ask the user whether to overwrite (default option)-n if the target file already exists, it will not overwrite the move, and do not ask the user-v to display the moving process of the file or directory-u if the target file already exists, but the two are compared When the source file is updated, the target file is upgraded [example 1] the mv command renames the file.

[root@bogon test] # ls test1 [root@bogon test] # mv test1 test [root@bogon test] # ls test [root@bogon test] #

As you can see, there is only one test1 file in the test directory, and with the mv command, we can flush the file as test.

[example 2] mv moves files or directories.

[root@bogon test] # pwd / root/test [root@bogon test] # cd.. [root@bogon ~] # ls Documents Videos demo [root@bogon ~] # mv / root/test demo [root@bogon ~] # cd demo [root@bogon demo] # ls test [root@bogon demo] # cd test [root@bogon test] # ls test [root@bogon test] #

As you can see, with the mv command, we moved the / root/test directory to the / root/demo directory.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

The above is how to use the mv command to move files and directories in the Linux system. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report