移动 (或更名) 文件、目录。
Ubuntu 跟 Windows 不同, 文件系统只有文件概念 (文件夹也会被视为文件); 因此, 不会出现文件夹 test 和文件 test 同时存在的情况。
mv /var/test /home/ftp
基本语法
mv [OPTION]... [-T] SOURCE DEST mv [OPTION]... SOURCE... DIRECTORY mv [OPTION]... -t DIRECTORY SOURCE...
注意:
长选项的强制性参数,对于短选项也是强制性的。
OPTION 选项
| 参数 | EN 解释 | 中文翻译 | Remarque |
|---|---|---|---|
| --backup[=CONTROL] | make a backup of each existing destination file | 为每个已存在目的地文件, 制作备份 | |
| -b | like --backup but does not accept an argument | 像 --backup, 但不接受自变量 | |
| -f, --force | do not prompt before overwriting | 覆写前不提示 |
若同时指定 -i -f -n, 仅最后一个生效。 |
| -i, --interactive | prompt before overwrite | 覆写前提示 | |
| -n, --no-clobber | do not overwrite an existing file | 不覆写现有文件 | |
| --strip-trailing-slashes | remove any trailing slashes from each SOURCE argument | 移除每个 SOURCE 自变量的任何结尾斜杠 | |
| -S, --suffix=SUFFIX | override the usual backup suffix | 覆盖常用备份后缀 | |
| -t, --target-directory=DIRECTORY | move all SOURCE arguments into DIRECTORY | 把所有 SOURCE 自变量移入 DIRECTORY | |
| -T, --no-target-directory | treat DEST as a normal file | 把 DEST 视为普通文件 | |
| -u, --update |
move only when the SOURCE file is newer than the destination file, or when the destination file is missing |
仅当 SOURCE 文件比目的地文件 更新时才移动, 或当目的地文件丢失时 |
|
| -v, --verbose | explain what is being done | 解释正在做什么 | |
| -Z, --context | set SELinux security context of destination file to default type |
把目的地文件 SELinux 安全上下文, 设为默认类型 |
|
| --help | display this help and exit | 显示此帮助并退出 | |
| --version | output version information and exit | 输出版本信息并退出 |
备份后缀为 ~, 除非采用 --suffix 或 SIMPLE_BACKUP_SUFFIX 进行设置。
版本控制方法可通过 --backup 选项或透过 VERSION_CONTROL 环境变量, 进行选择。
CONTROL 值
| 参数 | EN 解释 | 中文翻译 | Remarque |
|---|---|---|---|
| none, off | never make backups (even if --backup is given) | 从不制作备份 (即使 --backup 被给定) | |
| numbered, t | make numbered backups | 制作编号备份 | |
| existing, nil | numbered if numbered backups exist, simple otherwise | 编号备份, 若编号备份存在; 否则, 简单备份 | |
| simple, never | always make simple backups | 总是制作简单备份 |
| Fonction | Commande | 文字解释 | 示例 | 示例解释 |
|---|---|---|---|---|
| 文件 | mv File1 File2 | 把文件 File1 重命名 File2 | ||
| mv File Dir | 把文件 File 移到目录 Dir 下 | mv /var/lib/dpkg/info/* /home/ftp/inf | 把目录 info 下的一切,移到目录 /home/ftp/info 下 | |
| 目录 | mv Dir1 Dir2 | 把目录 Dir1 重命名 Dir2 | mv /var/lib/dpkg/info /home/ftp/info.bak | 把目录 info,移动并重命名为 info.bak |
| mv Dir1 Dir2 | 把目录 Dir1 移到 Dir2 下 | |||
| Version | mv --version | 展示版本信息 | ||
| 帮助 | mv --help | 展示帮助信息 |
版权声明: 本文为独家原创稿件,版权归 Logiciel Numérique Heureux ,未经许可不得转载。