Home  >  Article  >  Operation and Maintenance  >  How to move files in centos?

How to move files in centos?

coldplay.xixi
coldplay.xixiOriginal
2020-07-29 10:41:1610586browse

How to move files in centos: 1. Rename the file [file1.txt] to [file2.txt] and the code to [mv file1.txt file2.txt]; 2. Move the hscripts folder All files, code is [mv hscripts tmp].

How to move files in centos?

Centos method of moving files:

mv command is the abbreviation of move. Use it to move/rename files from directory to directory. The mv command is different from the cp command. The mv command completely moves the file from the source and moves the file to the specified directory. Here the cp command only copies the contents of the file from one file to another. a file.

Syntax:

mv [-f] [-i] 原名称 新名称

Command switches:

  • fDo not prompt before overwriting (equivalent to –reply=yes ). mv -f will move the file(s) silently, even if it overwrites an existing destination file.

  • iPrompt before copying another file

Example:

1. To Rename / Move a file:

mv file1.txt file2.txt

This command renames the file1.txt file to file2.txt.

2. To move a directory

mv hscripts tmp

In the above command, if the tmp directory already exists, the mv command will move all files, directories and subdirectories under the hscripts folder/directory to the tmp directory. If there is no tmp directory, it will rename the hscripts directory to the tmp directory.

3. Move multiple files/more files to another directory

mv file1.txt tmp/file2.txt newdir

This command moves the file1.txt file in the current directory and the file2.txt file in the tmp folder/directory to newdir Table of contents.

Recommended related tutorials: centos tutorial

The above is the detailed content of How to move files in centos?. 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