cp [-adDfiHLpPrRs] [-b size]
file1 [file2 . . . ] target
File1 is copied onto target. If target is an
existing regular file, its content is overwritten. Its mode and owner are
preserved; the mode of the source file is used otherwise.
If target is a directory, one or more files are copied into
the directory with their original file-names.
Cp refuses to copy a file onto itself.
The cp command accepts the following options:
- -i
- Cp will ask for confirmation before overwriting an existing target
file. For /usr/5bin/cp and /usr/5bin/s42/cp, cp will
also ask for confirmation before overwriting a directory with the
-r or -R option. For /usr/5bin/cp, this flag will be
automatically disabled if standard input is not a terminal.
- -p
- Cp will try to preserve access and modification times, user and
group ownerships, and file permission bits. Failing to preserve these
modes is always considered an error, but only /usr/5bin/s42/cp,
/usr/5bin/posix2001/cp, and /usr/5bin/posix/cp will print an
error message.
- -r
- The source file operands may be directories that will be copied
recursively. Symbolic links are followed. The content of all non-directory
files encountered is tried to be reproduced in a regular file.
The following options have been added by POSIX.2:
- -f
- If overwriting a target file fails, cp will try to unlink that file
and proceed.
- -R
- The source file operands may be directories that will be copied
recursively. Special files such as block and character devices, FIFOs, and
symbolic links encountered during traversal are recreated in the target
hierarchy. If a symbolic link is given as an operand, its target is
copied.
The following options have been added by POSIX.1-2001:
- -H
- With the -R option, follow symbolic links given as operands, but do
not follow symbolic links encountered during traversal of the source
hierarchy. This is the default.
- -L
- With the -R option, follow all symbolic links.
- -P
- With the -R option, do not follow any symbolic links.
The following options are extensions:
- -a
- Perform a recursive copy and, if possible, preserve hard links as well as
any attributes. This is the same as the combination of the -Rdp
options.
- -b size
- With this option given, cp performs input and output in units of
size bytes. The default size depends on the current input
file.
- -d
- With the -r or -R options, hard links between copied files
are usually splitted, i.e. each copied file is assigned to a separate
i-node. When this option is given, hard links between copied files are
reproduced in the destination hierarchy.
- -D
- Causes cp to use direct i/o when copying file data. See the
description of `O_DIRECT' in open(2) for more information.
- -s
- With this option, cp prints i/o statistics for each single file of
which data was copied.
cat(1), cpio(1), mv(1), pr(1), rm(1)
Use either
or
to copy files that begin with a hyphen character.
A copy of a symbolic link contains the same pathname as the
original. Symbolic links with relative pathnames may thus change or lose
their target if copied to a different level in the file hierarchy.