Home > Article > Operation and Maintenance > How to move files in centos?
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].
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:
f
Do not prompt before overwriting (equivalent to –reply=yes ). mv -f will move the file(s) silently, even if it overwrites an existing destination file.
i
Prompt 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!