cp(1)

cp(1)

-R(recursive subtree copy) The -Roption is identical to the -roption with the exception that directories copied by the -Roption are created with read, write, and search permission for the owner. User and group permissions remain unchanged.

With the -Rand -roptions, in addition to regular ®les and directories, cp also copies FIFOs, character and block device ®les and symbolic links. Only superusers can copy device ®les. All other users get an error. Symbolic links are copied so the target points to the same location that the source did.

Warning: While copying a directory tree that has device special ®les, use the -roption; otherwise, an in®nite amount of data is read from the device special ®le and is duplicated as a special ®le in the destination directory occupying large ®le system space.

-eextarg

Speci®es the handling of any extent attributes of the ®le[s] to be copied. extarg takes one of the following values.

warn Issues a warning message if extent attributes cannot be copied, but copies the ®le anyway.

ignore Does not copy the extent attributes.

force Fails to copy the ®le if the extent attribute can not be copied.

Extent attributes can not be copied if the ®les are being copied to a ®le system which does not support extent attributes or if that ®le system has a different block size than the original. If -eis not speci®ed, the default value for extarg is warn.

Access Control Lists (ACLs)

If new_®le is a new ®le, or if a new ®le is created in dest_directory, it inherits the access control list of the original ®le1, ®le2, etc., altered to re¯ect any difference in ownership between the two ®les (see acl(5) and aclv(5)). In JFS ®le systems, new ®les created by cp do not inherit their parent directory's default ACL entries (if any), but instead retain the ACLs of the ®les being copied. When copying ®les from a JFS ®le system to an HFS ®le system or vice versa, optional ACL entries are lost.

EXTERNAL INFLUENCES

Environment Variables

LC_CTYPE determines the interpretation of text as single and/or multi-byte characters.

LANG and LC_CTYPE determine the local language equivalent of y (for yes/no queries).

LANG determines the language in which messages are displayed.

If LC_CTYPE is not speci®ed in the environment or is set to the empty string, the value of LANG is used as a default for each unspeci®ed or empty variable. If LANG is not speci®ed or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG. If any internationalization variable contains an invalid setting, cp behaves as if all internationalization variables are set to "C". See environ(5).

International Code Set Support

Single- and multi-byte character code sets are supported.

EXAMPLES

The following command moves the directory sourcedir and its contents to a new location (targetdir) in the ®le system. Since cp creates the new directory, the destination directory targetdir should not already exist.

cp -rsourcedir targetdir && rm -rfsourcedir

The -roption copies the subtree (®les and subdirectories) in directory sourcedir to directory targetdir. The double ampersand (&&) causes a conditional action. If the operation on the left side of the && is suc- cessful, the right side is executed (and removes the old directory). If the operation on the left of the && is not successful, the old directory is not removed.

This example is equivalent to:

mv sourcedir targetdir

To copy all ®les and directory subtrees in the current directory to an existing targetdir, use:

cp -r * targetdir

HP-UX Release 11i: December 2000

− 2 −

Section 1115

c