cp [-r | -R [-H | -L | -P] ] [-fhipt] source_file target_file
cp [-r | -R [-H | -L | -P] ] [-fhipt] source_file ... target_directory
Description
In the first synopsis form, the cp utility copies the contents of the source_file to the target_file.
In the second synopsis form, the cp utility copies the contents of each named source_file to a file in the destination target_directory. The names of the files themselves are not changed. The target_directory must exist unless there is only one named source_file which is a directory and the -R flag is specified.
If cp detects an attempt to copy a file to itself, the copy will fail.
If target_file does not exist, the mode of the source_file is used, as modified by the file creation mask, when creating target_file. The S_ISUID and S_ISGID file permission bits are never set when creating a new file.
If target_file already exists and the -t option is not specified, its contents are overwritten as binary data and the CCSID attribute is changed to match the CCSID attribute of source_file. The file permission bits, owner, and group of target_file are unchanged. You can force the data to be copied as text data by using the -t option. You can force the file permission bits, owner, and group to be copied using the -p option.
Note that when copying to members in the QSYS.LIB file system, many attributes of source_file cannot be preserved because they are associated with the file object and not the member.
Symbolic links are always followed unless the -h option is specified or the -R option is specified with the -H or the -L options. The -H, -L and -P options are ignored unless the -R option is specified. In addition, these options override each other and the command's actions are determined by the last one specified.
Options
If the owner and group cannot be preserved, no error message is displayed and the exit value is not altered.
The S_ISUID and S_ISGID file permission bits are only copied when both the owner and group of the file are successfully copied.
Note: | This option has no effect when copying to the QSYS.LIB file system. |
Exit Status
Related information
cp file1 data.dir
cp -i code/*.java code/old_code.dir