Kerberized version.
[unix-history] / usr / src / bin / cp / cp.1
CommitLineData
a783899b
KB
1.\" Copyright (c) 1989 The Regents of the University of California.
2.\" All rights reserved.
c4c58dfe 3.\"
a783899b
KB
4.\" Redistribution and use in source and binary forms are permitted
5.\" provided that the above copyright notice and this paragraph are
6.\" duplicated in all such forms and that any documentation,
7.\" advertising materials, and other materials related to such
8.\" distribution and use acknowledge that the software was developed
9.\" by the University of California, Berkeley. The name of the
10.\" University may not be used to endorse or promote products derived
11.\" from this software without specific prior written permission.
12.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15.\"
24e5a125 16.\" @(#)cp.1 6.5 (Berkeley) %G%
c4c58dfe 17.\"
91e4161e 18.TH CP 1 ""
c4c58dfe
KM
19.UC 4
20.SH NAME
a783899b 21cp - copy files
c4c58dfe 22.SH SYNOPSIS
a783899b
KB
23\fBcp [ \fI-fhip\fB ] source_file target_file
24.sp
25\fBcp [ \fI-fhipr\fB ] source_file ... target_directory
26.ft R
c4c58dfe 27.SH DESCRIPTION
a783899b 28The
ec6dcb7a 29.I cp
a783899b
KB
30utility copies
31.I source_file
32to
33.I target_file
34or, in the second form, one or more
35.IR source_file s
36are copied into the target
37.IR target_directory ,
38retaining their original filenames.
39If
40.I cp
24e5a125
KB
41detects an attempt to copy a file to itself, the copy will fail.
42.PP
a783899b
KB
43For each destination file that already exists, its contents are
44overwritten if permissions allow, but its mode, user ID, and group
45ID are unchanged.
46Otherwise, the mode of the
47.I source_file
48is used as modified by the file mode creation mask.
49Appropriate permissions are required for file creation or overwriting.
c4c58dfe 50.PP
a783899b
KB
51The following options are available:
52.TP
53.I -h
54Forces
c4c58dfe 55.I cp
a783899b 56to follow symbolic links.
24e5a125
KB
57Provided for the
58.I -r
59option which does not follow symbolic links by default.
a783899b
KB
60.TP
61.I -f
24e5a125 62Force existing destination pathnames to be truncated before copying,
a783899b 63without prompting for confirmation.
24e5a125
KB
64(The
65.I -i
66option is ignored if the
67.I -f
68option is specified.)
a783899b
KB
69.TP
70.I -i
71Causes
c4c58dfe 72.I cp
a783899b
KB
73to write a prompt to standard error before copying a file that would
74overwrite an existing file.
75If the response from the standard input begins with the character ``y'',
76the file is copied if permissions allow the copy.
77.TP
78.I -p
79Causes
04d3a81e 80.I cp
a783899b 81to preserve in the copy as many of the modification time, access time,
24e5a125 82.\" and file mode as allowed by permissions.
a783899b
KB
83file mode, user ID, and group ID as allowed by permissions.
84.TP
85.I -r
86If
87.I source_file
88designates a directory,
89.I cp
90copies the directory and the entire subtree connected at that point.
91This option also causes symbolic links to be copied, rather than
92indirected through, and for
0493752e 93.I cp
a783899b 94to create special files rather than copying them as normal files.
24e5a125
KB
95Created directories have the same mode as the corresponding source
96directory, unmodified by the process' file mode creation mask.
a783899b
KB
97.PP
98Symbolic links are followed unless the
99.I -r
100option is specified, in which case the link itself is copied.
101.PP
102.I Cp
103exits 0 on success, >0 if an error occurred.
c4c58dfe 104.SH "SEE ALSO"
a783899b 105mv(1), rcp(1), umask(2)