• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# cp
2
3
4## Command Function
5
6This command is used to create a copy for a file.
7
8
9## Syntax
10
11cp [_SOURCEFILE_] [_DESTFILE_]
12
13
14## Parameters
15
16  **Table 1** Parameter description
17
18| Parameter| Description| Value Range|
19| -------- | -------- | -------- |
20| --help | Displays help information.| N/A |
21| SOURCEFILE | Specifies the file to copy.| This command does not support copy of a directory, but supports copy of multiple files at a time.|
22| DESTFILE | Specifies the file to create.| Both a directory and a file are supported.|
23
24
25## Usage Guidelines
26
27- The name of the source file cannot be the same as that of the destination file in the same path.
28
29- **SOURCEFILE** must exist and cannot be a directory.
30
31- The source file path supports asterisks (*) and question marks (?). The wildcard "\*" indicates any number of characters, and "?" indicates any single character. **DEST** does not support wildcard characters. If the specified **SOURCE** matches multiple files, **DEST** must be a directory.
32
33- If **DEST** is a directory, this directory must exist. In this case, the destination file is named after the source file.
34
35- If the destination file path is a file, the directory for this file must exist. In this case, the file copy is renamed.
36
37- If the destination file does not exist, a new file is created. If the destination file already exists, the existing file is overwritten.
38
39> **NOTICE**<br>
40> When important system resources are copied, unexpected results such as a system breakdown may occur. For example, when the **/dev/uartdev-1** file is copied, the system may stop responding.
41
42
43## Example
44
45Run **cp hello-OHOS.txt hello-openharmony.txt ./tmp/**.
46
47
48## Output
49
50Copy **hello-OHOS.txt** and **hello-openharmony.txt** to **/tmp/**.
51
52```
53OHOS:/$ ls
54bin  hello-OHOS.txt     proc     system    vendor
55dev  hello-openharmony.txt  sdcard   userdata
56etc  lib                storage  usr
57OHOS:/$ mkdir tmp
58OHOS:/$ cp hello-OHOS.txt hello-openharmony.txt tmp/
59OHOS:/$ ll tmp
60total 0
61-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 hello-OHOS.txt*
62-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 hello-openharmony.txt*
63```
64