Home >Operation and Maintenance >Linux Operation and Maintenance >How to use mv command to move files in linux

How to use mv command to move files in linux

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-05-11 17:10:4610741browse

In Linux, you can use the "[root@localhost ~]# mv option source file target file" statement to move files; the mv command (abbreviation of move) can move files between different directories or directory, you can also rename files and directories.

How to use mv command to move files in linux

#The operating environment of this tutorial: centos7 system, thinkpad t480 computer.

The mv command (abbreviation of move) can move files or directories between different directories, and can also rename files and directories. The basic format of this command is as follows:

[root@localhost ~]# mv 【选项】 源文件 目标文件

Options:

  • -f: Force overwriting. If the target file already exists, it will not ask and force overwriting directly;

  • -i: interactive movement, if the target file already exists, ask the user whether to overwrite (default option);

  • -n: if the target file If it already exists, the move will not be overwritten and the user will not be asked;

  • -v: Display the moving process of the file or directory;

  • - u: If the target file already exists, but the source file is newer than the two, the target file will be upgraded;

It should be noted that, similar to the rm command, the mv command It is also a destructive command. If used improperly, it is likely to bring disastrous consequences to the system.

(Recommended learning: linux tutorial)

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

Statement:
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