The cp utility shall conform to the Base Definitions volume of
POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
The following options shall be supported:
-f
If a file descriptor for a destination file cannot be
obtained, as described in step 3.a.ii., attempt to
unlink the destination file and proceed.
-H
Take actions based on the type and contents of the file
referenced by any symbolic link specified as a
source_file operand.
-i
Write a prompt to standard error before copying to any
existing non-directory destination file. If the
response from the standard input is affirmative, the
copy shall be attempted; otherwise, it shall not.
-L
Take actions based on the type and contents of the file
referenced by any symbolic link specified as a
source_file operand or any symbolic links encountered
during traversal of a file hierarchy.
-P
Take actions on any symbolic link specified as a
source_file operand or any symbolic link encountered
during traversal of a file hierarchy.
-p
Duplicate the following characteristics of each source
file in the corresponding destination file:
1. The time of last data modification and time of last
access. If this duplication fails for any reason,
cp shall write a diagnostic message to standard
error.
2. The user ID and group ID. If this duplication fails
for any reason, it is unspecified whether cp writes
a diagnostic message to standard error.
3. The file permission bits and the S_ISUID and
S_ISGID bits. Other, implementation-defined, bits
may be duplicated as well. If this duplication
fails for any reason, cp shall write a diagnostic
message to standard error.
If the user ID or the group ID cannot be duplicated,
the file permission bits S_ISUID and S_ISGID shall be
cleared. If these bits are present in the source file
but are not duplicated in the destination file, it is
unspecified whether cp writes a diagnostic message to
standard error.
The order in which the preceding characteristics are
duplicated is unspecified. The dest_file shall not be
deleted if these characteristics cannot be preserved.
-R
Copy file hierarchies.
Specifying more than one of the mutually-exclusive options -H
,
-L
, and -P
shall not be considered an error. The last option
specified shall determine the behavior of the utility.