Commit | Line | Data |
---|---|---|
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 | 21 | cp - 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 | 28 | The |
ec6dcb7a | 29 | .I cp |
a783899b KB |
30 | utility copies |
31 | .I source_file | |
32 | to | |
33 | .I target_file | |
34 | or, in the second form, one or more | |
35 | .IR source_file s | |
36 | are copied into the target | |
37 | .IR target_directory , | |
38 | retaining their original filenames. | |
39 | If | |
40 | .I cp | |
24e5a125 KB |
41 | detects an attempt to copy a file to itself, the copy will fail. |
42 | .PP | |
a783899b KB |
43 | For each destination file that already exists, its contents are |
44 | overwritten if permissions allow, but its mode, user ID, and group | |
45 | ID are unchanged. | |
46 | Otherwise, the mode of the | |
47 | .I source_file | |
48 | is used as modified by the file mode creation mask. | |
49 | Appropriate permissions are required for file creation or overwriting. | |
c4c58dfe | 50 | .PP |
a783899b KB |
51 | The following options are available: |
52 | .TP | |
53 | .I -h | |
54 | Forces | |
c4c58dfe | 55 | .I cp |
a783899b | 56 | to follow symbolic links. |
24e5a125 KB |
57 | Provided for the |
58 | .I -r | |
59 | option which does not follow symbolic links by default. | |
a783899b KB |
60 | .TP |
61 | .I -f | |
24e5a125 | 62 | Force existing destination pathnames to be truncated before copying, |
a783899b | 63 | without prompting for confirmation. |
24e5a125 KB |
64 | (The |
65 | .I -i | |
66 | option is ignored if the | |
67 | .I -f | |
68 | option is specified.) | |
a783899b KB |
69 | .TP |
70 | .I -i | |
71 | Causes | |
c4c58dfe | 72 | .I cp |
a783899b KB |
73 | to write a prompt to standard error before copying a file that would |
74 | overwrite an existing file. | |
75 | If the response from the standard input begins with the character ``y'', | |
76 | the file is copied if permissions allow the copy. | |
77 | .TP | |
78 | .I -p | |
79 | Causes | |
04d3a81e | 80 | .I cp |
a783899b | 81 | to preserve in the copy as many of the modification time, access time, |
24e5a125 | 82 | .\" and file mode as allowed by permissions. |
a783899b KB |
83 | file mode, user ID, and group ID as allowed by permissions. |
84 | .TP | |
85 | .I -r | |
86 | If | |
87 | .I source_file | |
88 | designates a directory, | |
89 | .I cp | |
90 | copies the directory and the entire subtree connected at that point. | |
91 | This option also causes symbolic links to be copied, rather than | |
92 | indirected through, and for | |
0493752e | 93 | .I cp |
a783899b | 94 | to create special files rather than copying them as normal files. |
24e5a125 KB |
95 | Created directories have the same mode as the corresponding source |
96 | directory, unmodified by the process' file mode creation mask. | |
a783899b KB |
97 | .PP |
98 | Symbolic links are followed unless the | |
99 | .I -r | |
100 | option is specified, in which case the link itself is copied. | |
101 | .PP | |
102 | .I Cp | |
103 | exits 0 on success, >0 if an error occurred. | |
c4c58dfe | 104 | .SH "SEE ALSO" |
a783899b | 105 | mv(1), rcp(1), umask(2) |