cp.1 (2012 03)
c
cp(1) cp(1)
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.
This example is equivalent to:
mv sourcedir targetdir
To copy all files and directory subtrees in the current directory to an existing targetdir , use:
cp -r * targetdir
To copy all files and directory subtrees in sourcedir to targetdir , use:
cp -r sourcedir /* targetdir
Note that directory pathnames can precede both sourcedir and targetdir .
To create a zero-length file, use any of the following:
cat /dev/null >file
cp /dev/null file
touch file
DEPENDENCIES
NFS
Access control lists of networked files are summarized (as returned in
st_mode by stat()), but not
copied to the new file. When using mv or ln on such files, a
+ is not printed after the mode value when
asking for permission to overwrite a file.
AUTHOR
cp was developed by AT&T, the University of California, Berkeley, and HP.
SEE ALSO
cpio(1), ln(1), mv(1), rm(1), link(1M), lstat(2), readlink(2), stat(2), symlink(2), symlink(4), acl(5), aclv(5),
standards(5).
STANDARDS CONFORMANCE
cp: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2
HP-UX 11i Version 3: March 2012 − 3 − Hewlett-Packard Company 3