1# rm 2 3 4## Command Function<a name="section181141523142613"></a> 5 6This command is used to delete a file or folder. 7 8## Syntax<a name="section8800926132619"></a> 9 10rm \[_-fv_\] _FILE or rm_ \[_-rv_\] \[_PATH_ | _filename_\]... 11 12## Parameters<a name="section15476229152617"></a> 13 14**Table 1** Parameter description 15 16<a name="table1507mcpsimp"></a> 17<table><thead align="left"><tr id="row1513mcpsimp"><th class="cellrowborder" valign="top" width="22.220000000000002%" id="mcps1.2.4.1.1"><p id="p1515mcpsimp"><a name="p1515mcpsimp"></a><a name="p1515mcpsimp"></a><strong id="b8231115224817"><a name="b8231115224817"></a><a name="b8231115224817"></a>Parameter</strong></p> 18</th> 19<th class="cellrowborder" valign="top" width="51.519999999999996%" id="mcps1.2.4.1.2"><p id="p1517mcpsimp"><a name="p1517mcpsimp"></a><a name="p1517mcpsimp"></a><strong id="b1599275514488"><a name="b1599275514488"></a><a name="b1599275514488"></a>Description</strong></p> 20</th> 21<th class="cellrowborder" valign="top" width="26.26%" id="mcps1.2.4.1.3"><p id="p1519mcpsimp"><a name="p1519mcpsimp"></a><a name="p1519mcpsimp"></a><strong id="b186611453114810"><a name="b186611453114810"></a><a name="b186611453114810"></a>Value Range</strong></p> 22</th> 23</tr> 24</thead> 25<tbody><tr id="row231513373307"><td class="cellrowborder" valign="top" width="22.220000000000002%" headers="mcps1.2.4.1.1 "><p id="p73091437173016"><a name="p73091437173016"></a><a name="p73091437173016"></a>-r</p> 26</td> 27<td class="cellrowborder" valign="top" width="51.519999999999996%" headers="mcps1.2.4.1.2 "><p id="p630917373307"><a name="p630917373307"></a><a name="p630917373307"></a>Deletes empty or non-empty directories.</p> 28</td> 29<td class="cellrowborder" valign="top" width="26.26%" headers="mcps1.2.4.1.3 "><p id="p1430943753016"><a name="p1430943753016"></a><a name="p1430943753016"></a>N/A</p> 30</td> 31</tr> 32<tr id="row1231583773013"><td class="cellrowborder" valign="top" width="22.220000000000002%" headers="mcps1.2.4.1.1 "><p id="p19309203763010"><a name="p19309203763010"></a><a name="p19309203763010"></a>-f</p> 33</td> 34<td class="cellrowborder" valign="top" width="51.519999999999996%" headers="mcps1.2.4.1.2 "><p id="p53092373308"><a name="p53092373308"></a><a name="p53092373308"></a>Deletes a file or directory forcibly without confirmation. No error will be reported when a file that does not exist is to be deleted.</p> 35</td> 36<td class="cellrowborder" valign="top" width="26.26%" headers="mcps1.2.4.1.3 "><p id="p8309937153018"><a name="p8309937153018"></a><a name="p8309937153018"></a>N/A</p> 37</td> 38</tr> 39<tr id="row331513719302"><td class="cellrowborder" valign="top" width="22.220000000000002%" headers="mcps1.2.4.1.1 "><p id="p5309103733013"><a name="p5309103733013"></a><a name="p5309103733013"></a>-v</p> 40</td> 41<td class="cellrowborder" valign="top" width="51.519999999999996%" headers="mcps1.2.4.1.2 "><p id="p1830913711300"><a name="p1830913711300"></a><a name="p1830913711300"></a>Displays the deletion process.</p> 42</td> 43<td class="cellrowborder" valign="top" width="26.26%" headers="mcps1.2.4.1.3 "><p id="p230933703015"><a name="p230933703015"></a><a name="p230933703015"></a>N/A</p> 44</td> 45</tr> 46<tr id="row173147371301"><td class="cellrowborder" valign="top" width="22.220000000000002%" headers="mcps1.2.4.1.1 "><p id="p14309143753012"><a name="p14309143753012"></a><a name="p14309143753012"></a>PATH/filename</p> 47</td> 48<td class="cellrowborder" valign="top" width="51.519999999999996%" headers="mcps1.2.4.1.2 "><p id="p193091637183016"><a name="p193091637183016"></a><a name="p193091637183016"></a>Specifies the name of the file or directory to delete. The value can be a path.</p> 49</td> 50<td class="cellrowborder" valign="top" width="26.26%" headers="mcps1.2.4.1.3 "><p id="p10309173711309"><a name="p10309173711309"></a><a name="p10309173711309"></a>N/A</p> 51</td> 52</tr> 53</tbody> 54</table> 55 56## Usage<a name="section10578163215262"></a> 57 58- The **rm** command can be used to delete multiple files or folders at a time. 59- You can run **rm -r** to delete a non-empty directory. 60- If the **rm** command without **-f** is used to delete a file that does not exist, an error will be reported. 61 62## Example<a name="section18548133511263"></a> 63 64Run the following commands: 65 66- rm testfile 67- rm -r testpath/ 68 69## Output<a name="section1565323814265"></a> 70 71Example 1: deleting **testfile** 72 73``` 74OHOS:/$ ls 75bin etc proc storage testfile usr 76dev lib sdcard system userdata vendor 77OHOS:/$ rm testfile 78OHOS:/$ ls 79bin etc proc storage userdata vendor 80dev lib sdcard system usr 81``` 82 83Example 2: deleting **testpath**, a non-empty directory 84 85``` 86OHOS:/$ ls 87bin etc proc storage testpath usr 88dev lib sdcard system userdata vendor 89OHOS:/$ rm -r testpath/ 90OHOS:/$ ls 91bin etc proc storage userdata vendor 92dev lib sdcard system usr 93``` 94 95