• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# touch
2
3
4## Command Function<a name="section17541924112716"></a>
5
6-   This command is used to create an empty file in a specified directory.
7-   If this command is executed to create an existing file, the execution will be successful but the timestamp will not be updated.
8
9## Syntax<a name="section866182711274"></a>
10
11touch \[_filename_\]
12
13## Parameters<a name="section268912296270"></a>
14
15**Table  1**  Parameter description
16
17<a name="table1635mcpsimp"></a>
18<table><thead align="left"><tr id="row1642mcpsimp"><th class="cellrowborder" valign="top" width="20.73%" id="mcps1.2.4.1.1"><p id="p1653mcpsimp"><a name="p1653mcpsimp"></a><a name="p1653mcpsimp"></a><strong id="b132581435193918"><a name="b132581435193918"></a><a name="b132581435193918"></a>Parameter</strong></p>
19</th>
20<th class="cellrowborder" valign="top" width="52.44%" id="mcps1.2.4.1.2"><p id="p1655mcpsimp"><a name="p1655mcpsimp"></a><a name="p1655mcpsimp"></a><strong id="b88661537163918"><a name="b88661537163918"></a><a name="b88661537163918"></a>Description</strong></p>
21</th>
22<th class="cellrowborder" valign="top" width="26.83%" id="mcps1.2.4.1.3"><p id="p1657mcpsimp"><a name="p1657mcpsimp"></a><a name="p1657mcpsimp"></a><strong id="b164851738193910"><a name="b164851738193910"></a><a name="b164851738193910"></a>Value Range</strong></p>
23</th>
24</tr>
25</thead>
26<tbody><tr id="row1323618419461"><td class="cellrowborder" valign="top" width="20.73%" headers="mcps1.2.4.1.1 "><p id="p1229443463"><a name="p1229443463"></a><a name="p1229443463"></a>--help</p>
27</td>
28<td class="cellrowborder" valign="top" width="52.44%" headers="mcps1.2.4.1.2 "><p id="p1122915417465"><a name="p1122915417465"></a><a name="p1122915417465"></a>Displays the parameters supported by the <strong id="b39321953125917"><a name="b39321953125917"></a><a name="b39321953125917"></a>touch</strong> command.</p>
29</td>
30<td class="cellrowborder" valign="top" width="26.83%" headers="mcps1.2.4.1.3 "><p id="p152291464613"><a name="p152291464613"></a><a name="p152291464613"></a>N/A</p>
31</td>
32</tr>
33<tr id="row82356419461"><td class="cellrowborder" valign="top" width="20.73%" headers="mcps1.2.4.1.1 "><p id="p322913424613"><a name="p322913424613"></a><a name="p322913424613"></a>filename</p>
34</td>
35<td class="cellrowborder" valign="top" width="52.44%" headers="mcps1.2.4.1.2 "><p id="p162291494614"><a name="p162291494614"></a><a name="p162291494614"></a>Specifies the name of the file to create.</p>
36</td>
37<td class="cellrowborder" valign="top" width="26.83%" headers="mcps1.2.4.1.3 "><p id="p182291242462"><a name="p182291242462"></a><a name="p182291242462"></a>N/A</p>
38</td>
39</tr>
40</tbody>
41</table>
42
43## Usage<a name="section412093332714"></a>
44
45-   The  **touch**  command creates an empty file that is readable and writeable.
46-   You can use the  **touch**  command to create multiple files at a time.
47
48    >![](../public_sys-resources/icon-notice.gif) **NOTICE:**
49    >If you run the  **touch**  command to create a file in a directory storing important system resources, unexpected results such as a system breakdown may occur. For example, if you run the  **touch uartdev-0**  command in the  **/dev**  directory, the system may stop responding.
50
51
52## Example<a name="section414434814354"></a>
53
54Run the following commands:
55
56-   touch file.c
57-   touch testfile1 testfile2 testfile3
58
59## Output<a name="section1028419515711"></a>
60
61Example 1: creating the  **file.c**  file
62
63```
64OHOS:/tmp$ ls
65OHOS:/tmp$ touch file.c
66OHOS:/tmp$ ls
67file.c
68OHOS:/tmp$ ll
69total 0
70-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 file.c*
71```
72
73Example 2: creating three files \(**testfile1**,  **testfile2**, and  **testfile3**\)
74
75```
76*OHOS:/tmp$
77OHOS:/tmp$ touch testfile1 testfile2 testfile3
78OHOS:/tmp$ ll
79total 0
80-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 testfile1*
81-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 testfile2*
82-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 testfile3*
83OHOS:/tmp$
84```
85
86