1e41f4b71Sopenharmony_ci# mv 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## 命令功能 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci移动文件。 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## 命令格式 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_cimv [_-fivn_] _SOURCE... DEST_ 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci## 参数说明 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci**表1** 参数说明 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| 参数 | 参数说明 | 取值范围 | 19e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ----------------------------------------------- | 20e41f4b71Sopenharmony_ci| -help | 使用帮助。 | N/A | 21e41f4b71Sopenharmony_ci| -f | 通过删除目标文件强制复制。 | N/A | 22e41f4b71Sopenharmony_ci| -i | 若指定移动的源目录或文件与目标中目录或文件同名,则会先询问是否覆盖旧文件,输入 y 直接覆盖,输入 n 取消该操作。 | N/A | 23e41f4b71Sopenharmony_ci| -n | 不要覆盖任何已存在的文件或目录。 | N/A | 24e41f4b71Sopenharmony_ci| -v | 目前本参数toybox官方最新代码虽然支持,但同样也不生效。 | N/A | 25e41f4b71Sopenharmony_ci| SOURCE | 源文件路径。 | 目前只支持文件,不支持目录;支持多文件同时移动。 | 26e41f4b71Sopenharmony_ci| DEST | 目的文件路径。 | 支持目录以及文件。 | 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci## 使用指南 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci- 源文件路径支持“\*”和“?”通配符,“\*”代表任意多个字符,“?”代表任意单个字符。目的路径不支持通配符。当源路径可匹配多个文件时,目的路径必须为目录。 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci- 目的路径为目录时,该目录必须存在。此时目的文件以源文件命名。 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci- 目的路径为文件时,所在目录必须存在。 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci- 目的文件已存在则会覆盖。 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci## 特殊说明 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_cishell端暂不支持。切换mksh版本可全支持,方法:cd bin; ./mksh。 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci## 使用实例 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci举例: 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci- mv -i test.txt testpath/ 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci- mv test?.txt testpath/ (移动 test3.txt testA.txt test_.txt) 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci## 输出说明 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci**示例1** 显示结果如下 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci``` 58e41f4b71Sopenharmony_ciOHOS:/$ touch test.txt 59e41f4b71Sopenharmony_ciOHOS:/$ mkdir testpath 60e41f4b71Sopenharmony_ciOHOS:/$ touch testpath/test.txt 61e41f4b71Sopenharmony_ciOHOS:/$ mv -i test.txt testpath/ 62e41f4b71Sopenharmony_cimv: overwrite 'testpath//test.txt' (Y/n):y 63e41f4b71Sopenharmony_ciOHOS:/$ ls 64e41f4b71Sopenharmony_cibin etc proc storage testpath usr 65e41f4b71Sopenharmony_cidev lib sdcard system userdata vendor 66e41f4b71Sopenharmony_ciOHOS:/$ cp testpath/test.txt ./ 67e41f4b71Sopenharmony_ciOHOS:/$ ls 68e41f4b71Sopenharmony_cibin etc proc storage test.txt userdata vendor 69e41f4b71Sopenharmony_cidev lib sdcard system testpath usr 70e41f4b71Sopenharmony_ciOHOS:/$ mv -i test.txt testpath/ 71e41f4b71Sopenharmony_cimv: overwrite 'testpath//test.txt' (Y/n):n 72e41f4b71Sopenharmony_ciOHOS:/$ ls 73e41f4b71Sopenharmony_cibin etc proc storage test.txt userdata vendor 74e41f4b71Sopenharmony_cidev lib sdcard system testpath usr 75e41f4b71Sopenharmony_ci``` 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci**示例2** 通配符使用 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci``` 81e41f4b71Sopenharmony_ciOHOS:/$ ls 82e41f4b71Sopenharmony_cibin etc proc storage test.txt testA.txt testpath usr 83e41f4b71Sopenharmony_cidev lib sdcard system test3.txt test_.txt userdata vendor 84e41f4b71Sopenharmony_ciOHOS:/$ mv test?.txt testpath/ 85e41f4b71Sopenharmony_ciOHOS:/$ ls 86e41f4b71Sopenharmony_cibin etc proc storage test.txt userdata vendor 87e41f4b71Sopenharmony_cidev lib sdcard system testpath usr 88e41f4b71Sopenharmony_ciOHOS:/$ ls testpath/ 89e41f4b71Sopenharmony_citest.txt test3.txt testA.txt test_.txt 90e41f4b71Sopenharmony_ci```