Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | .\" Copyright (c) 1989, 1990 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" This code is derived from software contributed to Berkeley by | |
5 | .\" the Institute of Electrical and Electronics Engineers, Inc. | |
6 | .\" | |
7 | .\" Redistribution and use in source and binary forms, with or without | |
8 | .\" modification, are permitted provided that the following conditions | |
9 | .\" are met: | |
10 | .\" 1. Redistributions of source code must retain the above copyright | |
11 | .\" notice, this list of conditions and the following disclaimer. | |
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer in the | |
14 | .\" documentation and/or other materials provided with the distribution. | |
15 | .\" 3. All advertising materials mentioning features or use of this software | |
16 | .\" must display the following acknowledgement: | |
17 | .\" This product includes software developed by the University of | |
18 | .\" California, Berkeley and its contributors. | |
19 | .\" 4. Neither the name of the University nor the names of its contributors | |
20 | .\" may be used to endorse or promote products derived from this software | |
21 | .\" without specific prior written permission. | |
22 | .\" | |
23 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
24 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
25 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
26 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
27 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
28 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
29 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
30 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
31 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
32 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
33 | .\" SUCH DAMAGE. | |
34 | .\" | |
35 | .\" @(#)cp.1 6.15 (Berkeley) 7/30/91 | |
36 | .\" | |
37 | .Dd July 30, 1991 | |
38 | .Dt CP 1 | |
39 | .Os BSD 4 | |
40 | .Sh NAME | |
41 | .Nm cp | |
42 | .Nd copy files | |
43 | .Sh SYNOPSIS | |
44 | .Nm cp | |
45 | .Op Fl Rfhip | |
46 | .Ar source_file target_file | |
47 | .Nm cp | |
48 | .Op Fl Rfhip | |
49 | .Ar source_file ... target_directory | |
50 | .Sh DESCRIPTION | |
51 | In the first synopsis form, the | |
52 | .Nm cp | |
53 | utility copies the contents of the | |
54 | .Ar source_file | |
55 | to the | |
56 | .Ar target_file . | |
57 | In the second synopsis form, | |
58 | the contents of each named | |
59 | .Ar source_file | |
60 | is copied to the destination | |
61 | .Ar target_directory . | |
62 | The names of the files themselves are not changed. | |
63 | If | |
64 | .Nm cp | |
65 | detects an attempt to copy a file to itself, the copy will fail. | |
66 | .Pp | |
67 | The following options are available: | |
68 | .Bl -tag -width flag | |
69 | .It Fl R | |
70 | If | |
71 | .Ar source_file | |
72 | designates a directory, | |
73 | .Nm cp | |
74 | copies the directory and the entire subtree connected at that point. | |
75 | This option also causes symbolic links to be copied, rather than | |
76 | indirected through, and for | |
77 | .Nm cp | |
78 | to create special files rather than copying them as normal files. | |
79 | Created directories have the same mode as the corresponding source | |
80 | directory, unmodified by the process' umask. | |
81 | .It Fl f | |
82 | For each existing destination pathname, remove it and | |
83 | create a new file, without prompting for confirmation | |
84 | regardless of its permissions. | |
85 | (The | |
86 | .Fl i | |
87 | option is ignored if the | |
88 | .Fl f | |
89 | option is specified.) | |
90 | .It Fl h | |
91 | Forces | |
92 | .Nm cp | |
93 | to follow symbolic links. | |
94 | Provided for the | |
95 | .Fl R | |
96 | option which does not follow symbolic links by default. | |
97 | .It Fl i | |
98 | Causes | |
99 | .Nm cp | |
100 | to write a prompt to standard error before copying a file that would | |
101 | overwrite an existing file. | |
102 | If the response from the standard input begins with the character | |
103 | .Sq Li y , | |
104 | the file is copied if permissions allow the copy. | |
105 | .It Fl p | |
106 | Causes | |
107 | .Nm cp | |
108 | to preserve in the copy as many of the modification time, access time, | |
109 | file mode, user ID, and group ID as allowed by permissions. | |
110 | .Pp | |
111 | If the user ID and group ID cannot be preserved, no error message | |
112 | is displayed and the exit value is not altered. | |
113 | .Pp | |
114 | If the source file has its set user ID bit on and the user ID cannot | |
115 | be preserved, the set user ID bit is not preserved | |
116 | in the copy's permissions. | |
117 | If the source file has its set group ID bit on and the group ID cannot | |
118 | be preserved, the set group ID bit is not preserved | |
119 | in the copy's permissions. | |
120 | If the source file has both the set user ID and set group ID bits | |
121 | on and either the user ID or group ID cannot be preserved, neither | |
122 | the set user ID or set group ID bits are preserved in the copy's | |
123 | permissions. | |
124 | .El | |
125 | .Pp | |
126 | For each destination file that already exists, its contents are | |
127 | overwritten if permissions allow, but its mode, user ID, and group | |
128 | ID are unchanged. | |
129 | .Pp | |
130 | If the destination file does not exist, the mode of the source file is | |
131 | used as modified by the file mode creation mask | |
132 | .Pf ( Ic umask , | |
133 | see | |
134 | .Xr csh 1 ) . | |
135 | If the source file has its set user ID bit on, that bit is removed | |
136 | unless both the source file and the destination file are owned by the | |
137 | same user. | |
138 | If the source file has its set group ID bit on, that bit is removed | |
139 | unless both the source file and the destination file are in the same | |
140 | group and the user is a member of that group. | |
141 | If both the set user ID and set group ID bits are set, all of the above | |
142 | conditions must be fulfilled or both bits are removed. | |
143 | .Pp | |
144 | Appropriate permissions are required for file creation or overwriting. | |
145 | .Pp | |
146 | Symbolic links are followed unless the | |
147 | .Fl R | |
148 | option is specified, in which case the link itself is copied. | |
149 | .Pp | |
150 | .Nm Cp | |
151 | exits 0 on success, >0 if an error occurred. | |
152 | .Sh SEE ALSO | |
153 | .Xr mv 1 , | |
154 | .Xr rcp 1 , | |
155 | .Xr umask 2 | |
156 | .Sh HISTORY | |
157 | The | |
158 | .Nm cp | |
159 | command is expected to be | |
160 | .St -p1003.2 | |
161 | compatible. |