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 | .\" | |
16 | .\" @(#)cp.1 6.4 (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 | |
41 | detects an attempt to copy a file to itself, the copy shall fail. | |
42 | For each destination file that already exists, its contents are | |
43 | overwritten if permissions allow, but its mode, user ID, and group | |
44 | ID are unchanged. | |
45 | Otherwise, the mode of the | |
46 | .I source_file | |
47 | is used as modified by the file mode creation mask. | |
48 | Appropriate permissions are required for file creation or overwriting. | |
c4c58dfe | 49 | .PP |
a783899b KB |
50 | The following options are available: |
51 | .TP | |
52 | .I -h | |
53 | Forces | |
c4c58dfe | 54 | .I cp |
a783899b KB |
55 | to follow symbolic links. |
56 | .TP | |
57 | .I -f | |
58 | Force existing destination pathnames to be removed before copying, | |
59 | without prompting for confirmation. | |
60 | .TP | |
61 | .I -i | |
62 | Causes | |
c4c58dfe | 63 | .I cp |
a783899b KB |
64 | to write a prompt to standard error before copying a file that would |
65 | overwrite an existing file. | |
66 | If the response from the standard input begins with the character ``y'', | |
67 | the file is copied if permissions allow the copy. | |
68 | .TP | |
69 | .I -p | |
70 | Causes | |
04d3a81e | 71 | .I cp |
a783899b KB |
72 | to preserve in the copy as many of the modification time, access time, |
73 | file mode, user ID, and group ID as allowed by permissions. | |
74 | .TP | |
75 | .I -r | |
76 | If | |
77 | .I source_file | |
78 | designates a directory, | |
79 | .I cp | |
80 | copies the directory and the entire subtree connected at that point. | |
81 | This option also causes symbolic links to be copied, rather than | |
82 | indirected through, and for | |
0493752e | 83 | .I cp |
a783899b KB |
84 | to create special files rather than copying them as normal files. |
85 | .PP | |
86 | The | |
87 | .I -i | |
88 | option is ignored if the | |
89 | .I -f | |
90 | option is specified. | |
91 | .PP | |
92 | Symbolic links are followed unless the | |
93 | .I -r | |
94 | option is specified, in which case the link itself is copied. | |
95 | .PP | |
96 | .I Cp | |
97 | exits 0 on success, >0 if an error occurred. | |
c4c58dfe | 98 | .SH "SEE ALSO" |
a783899b | 99 | mv(1), rcp(1), umask(2) |