1# mv 2 3 4## Command Function<a name="section201149459368"></a> 5 6This command is used to move files. 7 8## Syntax<a name="section579813484364"></a> 9 10mv \[_-fivn_\] _SOURCE... DEST_ 11 12## Parameters<a name="section168065311366"></a> 13 14**Table 1** Parameter description 15 16<a name="table1845mcpsimp"></a> 17<table><thead align="left"><tr id="row1851mcpsimp"><th class="cellrowborder" valign="top" width="20.84%" id="mcps1.2.4.1.1"><p id="p1853mcpsimp"><a name="p1853mcpsimp"></a><a name="p1853mcpsimp"></a>Parameter</p> 18</th> 19<th class="cellrowborder" valign="top" width="52.16%" id="mcps1.2.4.1.2"><p id="p1855mcpsimp"><a name="p1855mcpsimp"></a><a name="p1855mcpsimp"></a>Description</p> 20</th> 21<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1857mcpsimp"><a name="p1857mcpsimp"></a><a name="p1857mcpsimp"></a>Value Range</p> 22</th> 23</tr> 24</thead> 25<tbody><tr id="row20678165916440"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p126571859174418"><a name="p126571859174418"></a><a name="p126571859174418"></a>-help</p> 26</td> 27<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p1165745918447"><a name="p1165745918447"></a><a name="p1165745918447"></a>Displays help information.</p> 28</td> 29<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p165725913441"><a name="p165725913441"></a><a name="p165725913441"></a>N/A</p> 30</td> 31</tr> 32<tr id="row12678159174418"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p166571959164412"><a name="p166571959164412"></a><a name="p166571959164412"></a>-f</p> 33</td> 34<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p8657859134412"><a name="p8657859134412"></a><a name="p8657859134412"></a>Forcibly overwrites the target file.</p> 35</td> 36<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1965775904419"><a name="p1965775904419"></a><a name="p1965775904419"></a>N/A</p> 37</td> 38</tr> 39<tr id="row126781259104418"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p5657115954414"><a name="p5657115954414"></a><a name="p5657115954414"></a>-i</p> 40</td> 41<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p7657105917445"><a name="p7657105917445"></a><a name="p7657105917445"></a>Provides a prompt before moving a file that would overwrite an existing file. Enter <strong id="b886564463218"><a name="b886564463218"></a><a name="b886564463218"></a>y</strong> to overwrite the file or enter <strong id="b16826758113218"><a name="b16826758113218"></a><a name="b16826758113218"></a>n</strong> to cancel the operation.</p> 42</td> 43<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1165795924415"><a name="p1165795924415"></a><a name="p1165795924415"></a>N/A</p> 44</td> 45</tr> 46<tr id="row186773599442"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p86571059114410"><a name="p86571059114410"></a><a name="p86571059114410"></a>-n</p> 47</td> 48<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p36572059164415"><a name="p36572059164415"></a><a name="p36572059164415"></a>Do not overwrite any existing file or directory.</p> 49</td> 50<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1965715944417"><a name="p1965715944417"></a><a name="p1965715944417"></a>N/A</p> 51</td> 52</tr> 53<tr id="row66771159124413"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p15657185964416"><a name="p15657185964416"></a><a name="p15657185964416"></a>-v</p> 54</td> 55<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p166571759124418"><a name="p166571759124418"></a><a name="p166571759124418"></a>This parameter does not take effect although it is supported by the latest Toybox code.</p> 56</td> 57<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p12657059184418"><a name="p12657059184418"></a><a name="p12657059184418"></a>N/A</p> 58</td> 59</tr> 60<tr id="row11677145964419"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p2657205924414"><a name="p2657205924414"></a><a name="p2657205924414"></a>SOURCE</p> 61</td> 62<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p3657205924416"><a name="p3657205924416"></a><a name="p3657205924416"></a>Specifies the path of the source file.</p> 63</td> 64<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1365775904419"><a name="p1365775904419"></a><a name="p1365775904419"></a>This command cannot be used to move a directory. It can be used to move multiple files at a time.</p> 65</td> 66</tr> 67<tr id="row1267615917447"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p1658459144411"><a name="p1658459144411"></a><a name="p1658459144411"></a>DEST</p> 68</td> 69<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p265810599448"><a name="p265810599448"></a><a name="p265810599448"></a>Specifies the destination file path.</p> 70</td> 71<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p7658105914449"><a name="p7658105914449"></a><a name="p7658105914449"></a>Both a directory and a file are supported.</p> 72</td> 73</tr> 74</tbody> 75</table> 76 77## Usage<a name="section19190125723612"></a> 78 79- **SOURCE** supports wildcard characters \* and ?. The asterisk \(\*\) indicates any number of characters, and the question mark \(?\) represents a single character. **DEST** does not support wildcard characters. If the specified **SOURCE** matches multiple files, **DEST** must be a directory. 80- If **DEST** is a directory, this directory must exist. In this case, the destination file is named after the source file. 81- If **DEST** is a file, the directory for this file must exist. 82- If the destination file already exists, it will be overwritten. 83 84## Example<a name="section10383416372"></a> 85 86Run the following commands: 87 88- mv -i test.txt testpath/ 89- mv test?.txt testpath/ \(Move **test3.txt**, **testA.txt**, and **test\_.txt**\) 90 91## Output<a name="section131601649114511"></a> 92 93Example 1: moving a file 94 95``` 96OHOS:/$ touch test.txt 97OHOS:/$ mkdir testpath 98OHOS:/$ touch testpath/test.txt 99OHOS:/$ mv -i test.txt testpath/ 100mv: overwrite 'testpath//test.txt' (Y/n):y 101OHOS:/$ ls 102bin etc proc storage testpath usr 103dev lib sdcard system userdata vendor 104OHOS:/$ cp testpath/test.txt ./ 105OHOS:/$ ls 106bin etc proc storage test.txt userdata vendor 107dev lib sdcard system testpath usr 108OHOS:/$ mv -i test.txt testpath/ 109mv: overwrite 'testpath//test.txt' (Y/n):n 110OHOS:/$ ls 111bin etc proc storage test.txt userdata vendor 112dev lib sdcard system testpath usr 113``` 114 115Example 2: moving files using wildcards 116 117``` 118OHOS:/$ ls 119bin etc proc storage test.txt testA.txt testpath usr 120dev lib sdcard system test3.txt test_.txt userdata vendor 121OHOS:/$ mv test?.txt testpath/ 122OHOS:/$ ls 123bin etc proc storage test.txt userdata vendor 124dev lib sdcard system testpath usr 125OHOS:/$ ls testpath/ 126test.txt test3.txt testA.txt test_.txt 127``` 128 129