• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# touch
2
3
4## Command Function
5
6- This command is used to create an empty file in a specified directory.
7
8- If this command is executed to create an existing file, the execution will be successful but the timestamp will not be updated.
9
10
11## Syntax
12
13touch [_filename_]
14
15
16## Parameters
17
18  **Table 1** Parameter description
19
20| Parameter    | Description                   | Value Range|
21| -------- | --------------------------- | -------- |
22| --help   | Displays the parameters supported by the **touch** command.| N/A      |
23| filename | Specifies the name of the file to create.       | N/A      |
24
25
26## Usage Guidelines
27
28- The **touch** command creates an empty file that is readable and writeable.
29
30- You can use the **touch** command to create multiple files at a time.
31
32  > **NOTICE**<br>
33  > 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.
34
35## Note
36
37The shell does not support **--help**  or creation of multiple files at the same time. mksh supports it. To switch to mksh, run **cd bin** and **./mksh**.
38
39## Example
40
41Run the following commands:
42
43- touch file.c
44
45- touch testfile1 testfile2 testfile3
46
47
48## Output
49
50Example 1: Create a file named **file.c**.
51
52
53```
54OHOS:/tmp$ ls
55OHOS:/tmp$ touch file.c
56OHOS:/tmp$ ls
57file.c
58OHOS:/tmp$ ll
59total 0
60-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 file.c*
61```
62
63Example 2: Create three files (**testfile1**, **testfile2**, and **testfile3**) at a time.
64
65
66```
67*OHOS:/tmp$
68OHOS:/tmp$ touch testfile1 testfile2 testfile3
69OHOS:/tmp$ ll
70total 0
71-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 testfile1*
72-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 testfile2*
73-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 testfile3*
74OHOS:/tmp$
75```
76