.TH cp "" "" Command
.PC "Copy a file"
\fBcp [ \-d ] \fI oldname newname\fR
\fBcp [ \-d ] \fI file1 ... fileN directory\fR
.PP
.HS
.SH Option:
.IC \fB\-d\fR
Preserve date (\fImtime\fR) on destination files.
.HE
.B cp
copies files.
In its first form,
.B cp
copies the contents of
.I oldname
to
.IR newname ,
which it creates if necessary.
If
.I newname
is a directory,
.B cp
copies
.I oldname
to a file of the same name in directory
.IR newfile .
.PP
In its second form,
.B cp
copies each
.IR file ,
from
.I file1
through
.IR fileN ,
into
.I directory.
.PP
With the
.B \-d
option,
.B cp
preserves the date (modification time)
of the source file or files on the target file or files.
By default,
target files get the current time.
.PP
A file cannot be copied to itself.
.SH "See Also"
.Xr "commands," commands
.Xr "cpdir," cpdir
.Xr "ksh," ksh
.Xr "mv," mv
.Xr "sh," sh
.Xr "wildcards" wildcards
.SH Notes
If you use
.B cp
to copy a file into another existing file, the newly
copied file takes on the permissions of the file into which the text
was copied.
For example, consider the files
.B foo
and
.BR bar ,
whose permissions are as follows:
.DM
	-rw-r--r--  1 fred       user            40 Tue Apr 14 18:19 bar
	-rw-r-----  1 fred       user          1816 Tue Apr 14 20:53 foo
.DE
.PP
If you use
.B cp
to copy
.B foo
into
.BR bar ,
then typing
.B "ls -l"
shows the following:
.DM
	-rw-r--r--  1 fred       user          1816 Tue Apr 14 21:37 bar
	-rw-r-----  1 fred       user          1816 Tue Apr 14 20:53 foo
.DE
.PP
.B bar
now has exactly the same contents as
.B foo
but retains its old set of permissions.
