linux mv 命令
Linux mv command is used to move or rename files. We generally provide the source and destination files and directories to mv
command.
Linux mv命令用于移动或重命名文件。 我们通常向mv
命令提供源文件和目标文件以及目录。
mv命令语法 (mv Command Syntax)
The Linux mv command has the following simple syntax where SOURCE and DESTINATION are a must.
Linux mv命令具有以下简单语法,其中SOURCE和DESTINATION是必须的。
mv [OPTION]... SOURCE... DESTINATION
- SOURCE is the source file or directory which will be moved to the DESTINATION SOURCE是将被移至DESTINATION的源文件或目录
- DESTINATION is the destination file or folder which will be moved from the SOURCEDESTINATION是将从源中移出的目标文件或文件夹
- OPTION is used to change provides different behavior for the mv command and optional by default.OPTION用于更改,为mv命令提供不同的行为,默认情况下为可选。
移动文件或文件夹 (Move File or Folder)
The regular usage of mv
command is moving files or directories. We will provide source files or directory and destination file or directory. In this example, we will move or rename directory named backup
into live
.
mv
命令的常规用法是移动文件或目录。 我们将提供源文件或目录以及目标文件或目录。 在此示例中,我们将名为backup
目录移动或重命名为live
。
$ mv backup live
强制移动文件或文件夹 (Force Moving File or Folder)
If there are files and folders in the destination the mv command will stop moving. We can force move operation with -f
option.
如果目标中有文件和文件夹,则mv命令将停止移动。 我们可以使用-f
选项强制执行移动操作。
$ mv -f backup live
覆盖前询问 (Ask Before Overwrite)
We can prompt before overwriting the destination file. We will use -i
option for this. In order to accept overwrite we should answer with y
or Y
.
我们可以在覆盖目标文件之前提示。 我们将使用-i
选项。 为了接受覆盖,我们应该用y
或Y
回答。
$ mv -i backup live
详细模式–打印所有移动操作 (Verbose Mode – Print Every Move Operation)
While moving files we may need to list all moved files. We call this verbose
mode. This will list moved files line by line with -v
option like below.
移动文件时,我们可能需要列出所有移动文件。 我们称这种verbose
模式。 这将使用-v
选项逐行列出移动的文件,如下所示。
$ mv -v backup live
翻译自: https://www.poftut.com/linux-mv-command-tutorial-examples-move-files/
linux mv 命令