Print this page
12745 man page typos
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man1/cp.1.man.txt
+++ new/usr/src/man/man1/cp.1.man.txt
1 1 CP(1) User Commands CP(1)
2 2
3 3
4 4
5 5 NAME
6 6 cp - copy files
7 7
8 8 SYNOPSIS
9 9 /usr/bin/cp [-afip@/] source_file target_file
10 10
11 11
12 12 /usr/bin/cp [-afip@/] source_file... target
13 13
14 14
15 15 /usr/bin/cp [-r | -R [-H | -L | -P]] [-afip@/] source_dir... target
16 16
17 17
18 18 /usr/bin/cp [-R | -R [-H | -L | -P]] [-afip@/] source_dir... target
19 19
20 20
21 21 /usr/xpg4/bin/cp [-afip@/] source_file target_file
22 22
23 23
24 24 /usr/xpg4/bin/cp [-afip@/] source_file... target
25 25
26 26
27 27 /usr/xpg4/bin/cp [-r | -R [-H | -L | -P]] [-afip@/] source_dir... target
28 28
29 29
30 30 /usr/xpg4/bin/cp [-R | -R [-H | -L | -P]] [-afip@/] source_dir... target
31 31
32 32
33 33 DESCRIPTION
34 34 In the first synopsis form, neither source_file nor target_file are
35 35 directory files, nor can they have the same name. The cp utility copies
36 36 the contents of source_file to the destination path named by
37 37 target_file. If target_file exists, cp overwrites its contents, but the
38 38 mode (and ACL if applicable), owner, and group associated with it are
39 39 not changed. The last modification time of target_file and the last
40 40 access time of source_file are set to the time the copy was made. If
41 41 target_file does not exist, cp creates a new file named target_file
42 42 that has the same mode as source_file except that the sticky bit is not
43 43 set unless the user is super-user. In this case, the owner and group of
44 44 target_file are those of the user, unless the setgid bit is set on the
45 45 directory containing the newly created file. If the directory's setgid
46 46 bit is set, the newly created file has the group of the containing
47 47 directory rather than of the creating user. If target_file is a link to
48 48 another file, cp overwrites the link destination with the contents of
49 49 source_file; the link(s) from target_file remains.
50 50
51 51
52 52 In the second synopsis form, one or more source_files are copied to the
53 53 directory specified by target. It is an error if any source_file is a
54 54 file of type directory, if target either does not exist or is not a
55 55 directory.
56 56
57 57
58 58 In the third or fourth synopsis forms, one or more directories
59 59 specified by source_dir are copied to the directory specified by
60 60 target. Either the -r or -R must be specified. For each source_dir, cp
61 61 copies all files and subdirectories.
62 62
63 63 OPTIONS
64 64 The following options are supported for both /usr/bin/cp and
65 65 /usr/xpg4/bin/cp:
66 66
67 67 -a
68 68 Archive mode. Same as -RpP.
69 69
70 70
71 71 -f
72 72 Unlink. If a file descriptor for a destination file cannot be
73 73 obtained, this option attempts to unlink the destination file and
74 74 proceed.
75 75
76 76
77 77 -H
78 78 Takes actions based on the type and contents of the file
79 79 referenced by any symbolic link specified as a source_file
80 80 operand.
81 81
82 82 If the source_file operand is a symbolic link, then cp copies the
83 83 file referenced by the symbolic link for the source_file operand.
84 84 All other symbolic links encountered during traversal of a file
85 85 hierarchy are preserved.
86 86
87 87
88 88 -i
89 89 Interactive. cp prompts for confirmation whenever the copy would
90 90 overwrite an existing target. An affirmative response means that
91 91 the copy should proceed. Any other answer prevents cp from
92 92 overwriting target.
93 93
94 94
95 95 -L
96 96 Takes actions based on the type and contents of the file
97 97 referenced by any symbolic link specified as a source_file
98 98 operand or any symbolic links encountered during traversal of a
99 99 file hierarchy.
100 100
101 101 Copies files referenced by symbolic links. Symbolic links
102 102 encountered during traversal of a file hierarchy are not
103 103 preserved.
104 104
105 105
106 106 -p
107 107 Preserve. The cp utility duplicates not only the contents of
108 108 source_file, but also attempts to preserve its ACL, access and
109 109 modification times, extended attributes, extended system
110 110 attributes, file mode, and owner and group ids.
111 111
112 112 If cp is unable to preserve the access and modification times,
113 113 extended attributes, or the file mode, cp does not consider it a
114 114 failure. If cp is unable to preserve the owner and group id, the
115 115 copy does not fail, but cp silently clears the S_ISUID and
116 116 S_ISGID bits from the file mode of the target. The copy fails if
117 117 cp is unable to clear these bits. If cp is unable to preserve the
118 118 ACL or extended system attributes, the copy fails. If the copy
119 119 fails, then a diagnostic message is written to stderr and (after
120 120 processing any remaining operands) cp exits with a non-zero exit
121 121 status.
122 122
123 123
124 124 -P
125 125 Takes actions on any symbolic link specified as a source_file
126 126 operand or any symbolic link encountered during traversal of a
127 127 file hierarchy.
128 128
129 129 Copies symbolic links. Symbolic links encountered during
130 130 traversal of a file hierarchy are preserved.
131 131
132 132
133 133 -r
134 134 Recursive. cp copies the directory and all its files, including
135 135 any subdirectories and their files to target. Unless the -H, -L,
136 136 or -P option is specified, the -L option is used as the default
137 137 mode.
138 138
139 139
140 140 -R
141 141 Same as -r, except pipes are replicated, not read from.
142 142
143 143
144 144 -@
145 145 Preserves extended attributes. cp attempts to copy all of the
146 146 source file's extended attributes along with the file data to the
147 147 destination file.
148 148
149 149
150 150 -/
151 151 Preserves extended attributes and extended system attributes.
152 152 Along with the file's data, the cp utility attempts to copy
153 153 extended attributes and extended system attributes from each
154 154 source file, and extended system attributes associated with
155 155 extended attributes to the destination file. If cp is unable to
156 156 copy extended attributes or extended system attributes, then a
157 157 diagnostic message is written to stderr and (after processing any
158 158 remaining operands) exits with a non-zero exit status.
159 159
160 160
161 161
162 162 Specifying more than one of the mutually-exclusive options -H, -L, and
163 163 -P is not considered an error. The last option specified determines the
164 164 behavior of the utility.
165 165
166 166 /usr/bin/cp
167 167 If the -p option is specified with either the -@ option or the -/
168 168 option, /usr/bin/cp behaves as follows
169 169
170 170 o When both -p and -@ are specified in any order, the copy
171 171 fails if extended attributes cannot be copied.
172 172
173 173 o When both -p and -/ are specified in any order, the copy
174 174 fails if extended system attributes cannot be copied.
175 175
176 176 /usr/xpg4/bin/cp
177 177 If the -p option is specified with either the -@ option or the -/
178 178 option, /usr/xpg4/bin/cp behaves as follows:
179 179
180 180 o When both -p and -@ are specified, the last option specified
181 181 determines whether the copy fails if extended attributes
182 182 cannot be preserved.
183 183
184 184 o When both -p and -/ are specified, the last option specified
185 185 determines whether the copy fails if extended system
186 186 attributes cannot be preserved.
187 187
188 188 OPERANDS
189 189 The following operands are supported:
190 190
191 191 source_file
192 192 A pathname of a regular file to be copied.
193 193
194 194
195 195 source_dir
196 196 A pathname of a directory to be copied.
197 197
198 198
199 199 target_file
200 200 A pathname of an existing or non-existing file, used for
201 201 the output when a single file is copied.
202 202
203 203
204 204 target
205 205 A pathname of a directory to contain the copied files.
206 206
207 207
208 208 USAGE
209 209 See largefile(5) for the description of the behavior of cp when
210 210 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
211 211
212 212 EXAMPLES
213 213 Example 1 Copying a File
214 214
215 215
216 216 The following example copies a file:
217 217
218 218
219 219 example% cp goodies goodies.old
220 220
221 221 example% ls goodies*
222 222 goodies goodies.old
223 223
224 224
225 225
226 226 Example 2 Copying a List of Files
227 227
228 228
229 229 The following example copies a list of files to a destination
230 230 directory:
231 231
232 232
233 233 example% cp ~/src/* /tmp
234 234
235 235
236 236
237 237 Example 3 Copying a Directory
238 238
239 239
240 240 The following example copies a directory, first to a new, and then to
241 241 an existing destination directory
242 242
243 243
244 244 example% ls ~/bkup
245 245 /usr/example/fred/bkup not found
246 246
247 247 example% cp -r ~/src ~/bkup
248 248
249 249 example% ls -R ~/bkup
250 250 x.c y.c z.sh
251 251
252 252 example% cp -r ~/src ~/bkup
253 253
254 254 example% ls -R ~/bkup
255 255 src x.c y.c z.sh
256 256 src:
257 257 x.c y.c z.s
258 258
259 259
260 260
261 261 Example 4 Copying Extended File System Attributes
262 262
263 263
264 264 The following example copies extended file system attributes:
265 265
266 266
267 267 $ ls -/ c file1
268 268 -rw-r--r-- 1 foo staff 0 Oct 29 20:04 file1
269 269 {AH-----m--}
270 270
271 271 $ cp -/ file1 file2
272 272 $ ls -/c file2
273 273 -rw-r--r-- 1 foo staff 0 Oct 29 20:17 file2
274 274 {AH-----m--}
275 275
276 276
277 277
278 278 Example 5 Failing to Copy Extended System Attributes
279 279
280 280
281 281 The following example fails to copy extended system attributes:
282 282
283 283
284 284 $ ls -/c file1
285 285 -rw-r--r-- 1 foo staff 0 Oct 29 20:04 file1
286 286 {AH-----m--}
287 287
288 288 $ cp -/ file1 /tmp
289 289 cp: Failed to copy extended system attributes from file1 to /tmp/file1
290 290
291 291
292 292 $ ls -/c /tmp/file1
293 293 -rw-r--r-- 1 foo staff 0 Oct 29 20:09 /tmp/file1
294 294 {}
295 295
296 296
297 297
298 298 ENVIRONMENT VARIABLES
299 299 See environ(5) for descriptions of the following environment variables
300 300 that affect the execution of cp: LANG, LC_ALL, LC_COLLATE, LC_CTYPE,
301 301 LC_MESSAGES, and NLSPATH.
302 302
303 303
304 304 Affirmative responses are processed using the extended regular
305 305 expression defined for the yesexpr keyword in the LC_MESSAGES category
306 306 of the user's locale. The locale specified in the LC_COLLATE category
307 307 defines the behavior of ranges, equivalence classes, and multi-
308 308 character collating elements used in the expression defined for
309 309 yesexpr. The locale specified in LC_CTYPE determines the locale for
310 310 interpretation of sequences of bytes of text data a characters, the
311 311 behavior of character classes used in the expression defined for the
312 312 yesexpr. See locale(5).
313 313
314 314 EXIT STATUS
315 315 The following exit values are returned:
316 316
317 317 0
318 318 All files were copied successfully.
319 319
↓ open down ↓ |
319 lines elided |
↑ open up ↑ |
320 320
321 321 >0
322 322 An error occurred.
323 323
324 324
325 325 ATTRIBUTES
326 326 See attributes(5) for descriptions of the following attributes:
327 327
328 328 /usr/bin/cp
329 329
330 -
331 -
332 330 +--------------------+-----------------+
333 331 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
334 332 +--------------------+-----------------+
335 333 |CSI | Enabled |
336 334 +--------------------+-----------------+
337 335 |Interface Stability | Committed |
338 336 +--------------------+-----------------+
339 337
340 338 /usr/xpg4/bin/cp
341 339
342 -
343 -
344 340 +--------------------+-----------------+
345 341 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
346 342 +--------------------+-----------------+
347 343 |CSI | Enabled |
348 344 +--------------------+-----------------+
349 345 |Interface Stability | Committed |
350 346 +--------------------+-----------------+
351 347
352 348 SEE ALSO
353 349 chmod(1), chown(1), setfacl(1), utime(2), fgetattr(3C), attributes(5),
354 350 environ(5), fsattr(5), largefile(5), locale(5), standards(5)
355 351
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
356 352 NOTES
357 353 The permission modes of the source file are preserved in the copy.
358 354
359 355
360 356 A -- permits the user to mark the end of any command line options
361 357 explicitly, thus allowing cp to recognize filename arguments that begin
362 358 with a -.
363 359
364 360
365 361
366 - April 15, 2013 CP(1)
362 + May 17, 2020 CP(1)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX