HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)
c
cp(1) cp(1)
Under UNIX95 flag set, cp will exit with error if multiple sources are being copied to a non-
existing directory.
-R (recursive subtree copy) The -R option is identical to the
-r option.
With the
-R and -r options, in addition to regular files and directories,
cp also copies FIFOs,
character and block device files and symbolic links. Only superusers can copy device files. 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 files, use the
-r option; otherwise,
an infinite amount of data is read from the device special file and is duplicated as a special file in
the destination directory occupying large file system space.
-e extarg
Specifies the handling of any extent attributes of the file[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 file
anyway.
ignore Does not copy the extent attributes.
force Fails to copy the file if the extent attribute can not be copied.
Extent attributes can not be copied if the files are being copied to a file system which does not sup-
port extent attributes or if that file system has a different block size than the original. If
-e is not
specified, the default value for extarg is
warn.
-S Specifies "safe" mode. This minimizes the impact of cp
on the performance of the system by open-
ing the target file using the
O_DSYNC flag. This is recommended when the total size of the copy
(not of a single file) is a significant portion of the size of system buffer cache. Usage of this option
increases copy time.
Access Control Lists (ACLs)
If new_file is a new file, or if a new file is created in dest_directory, it inherits the access control list of the
original file1, file2, etc., altered to reflect any difference in ownership between the two files (see acl(5) and
aclv(5)). In JFS file systems, new files created by
cp do not inherit their parent directory’s default ACL
entries (if any), but instead retain the ACLs of the files being copied. When copying files from a JFS file
system to an HFS file system or vice versa, optional ACL entries are lost.
EXTERNAL INFLUENCES
Environment Variables
UNIX95 specifies using the XPG4 behaviour for this command.
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 specified in the environment or is set to the empty string, the value of
LANG is used as
a default for each unspecified or empty variable. If
LANG is not specified 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
file system. Since
cp creates the new directory, the destination directory targetdir should not already
exist.
cp -r sourcedir targetdir && rm -rf sourcedir
The -r option copies the subtree (files 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.
HP-UX 11i Version 1: September 2005 − 2 − Hewlett-Packard Company Section 1−−115