cp
Command Function
This command is used to create a copy for a file.
Syntax
cp [SOURCEFILE] [DESTFILE]
Parameters
Table 1 Parameter description
Currently, only files are supported. Directories are not supported. |
||
Usage
- The name of the source file cannot be the same as that of the destination file in the same path.
- The source file must exist and cannot be a directory.
- The source file path supports wildcards asterisk (*) and question mark(?). The asterisk (*) indicates any number of characters, and the question mark (?) indicates any single character. The destination path does not support wildcards. If the source path matches multiple files, the destination path must be a directory.
- If the destination file path is a directory, this directory must exist. In this case, the destination file is named after the source file.
- If the destination file path is a file, the directory for this file must exist. In this case, the file copy is renamed.
- Currently, this command can be used to copy only one file. If more than two parameters are specified, only the first two parameters take effect.
- If the destination file does not exist, a new file is created. If the destination file already exists, the existing file is overwritten.
When important system resources are copied, unexpected results such as a system breakdown may occur. For example, when the /dev/uartdev-0 file is copied, the system may stop responding.
Example
Run cp hello-harmony.txt ./tmp/.