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

Use the mv command of linux to move or rename a file

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Editor to share with you the use of linux mv command to move or rename files, I hope you will learn a lot after reading this article, let's discuss it together!

The mv command is an acronym for the word "move" and has roughly the same function as in English. You can move a file or rename it.

This is a file management command that is used very frequently, and we need to pay special attention to the difference between mv and replication: the results of mv and cp are different. The mv command is like a file "move". The name of the file has changed, but the number has not increased. The cp command is to copy files, and the number of files is increasing.

Syntax format: mv [parameters]

Common parameters:

-I if a file with the same name exists, ask the user if you want to overwrite the existing file without prompting-b create a backup-u for the file before overwriting when it exists

Move this operation only when the source file is newer than the target file, or when the target file does not exist

Reference example

Rename the file file_1 to file_2:

[root@linuxcool ~] # mv file_1 file_2

Move the file file to the directory dir:

[root@linuxcool ~] # mv file / dir

Move the directory dir1 to the directory dir2 (if directory dir2 already exists, rename it if it does not exist):

[root@linuxcool ~] # mv / dir1 / dir2

Move the files under the directory dir1 to the current directory:

[root@linuxcool] # mv / dir1/*. After reading this article, I believe you have some understanding of moving or renaming documents using linux's mv command. If you want to know more about it, welcome to follow the industry information channel. Thank you for your reading!

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

Servers

Wechat

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

12
Report