linux mv 命令_Linux mv命令教程

linux mv 命令

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 SOURCE

    DESTINATION是将从源中移出的目标文件或文件夹
  • 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选项。 为了接受覆盖,我们应该用yY回答。

$ 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
LEARN MORE  How To Set Permission For Folders and Subfolders in Linux
了解更多信息如何在Linux中设置文件夹和子文件夹的权限

翻译自: https://www.poftut.com/linux-mv-command-tutorial-examples-move-files/

linux mv 命令

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值