cp.1 (2010 09)
c
cp(1) cp(1)
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: September 2010 − 3 − Hewlett-Packard Company 3