Print this page
12745 man page typos
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man1/cp.1
+++ new/usr/src/man/man1/cp.1
1 1 .\"
2 2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 3 .\" permission to reproduce portions of its copyrighted documentation.
4 4 .\" Original documentation from The Open Group can be obtained online at
5 5 .\" http://www.opengroup.org/bookstore/.
6 6 .\"
7 7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 8 .\" Group, have given us permission to reprint portions of their
9 9 .\" documentation.
10 10 .\"
11 11 .\" In the following statement, the phrase ``this text'' refers to portions
12 12 .\" of the system documentation.
13 13 .\"
14 14 .\" Portions of this text are reprinted and reproduced in electronic form
15 15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 16 .\" Standard for Information Technology -- Portable Operating System
17 17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 20 .\" between these versions and the original IEEE and The Open Group
21 21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 22 .\" document. The original Standard can be obtained online at
23 23 .\" http://www.opengroup.org/unix/online.html.
24 24 .\"
25 25 .\" This notice shall appear on any product containing this material.
26 26 .\"
27 27 .\" The contents of this file are subject to the terms of the
28 28 .\" Common Development and Distribution License (the "License").
29 29 .\" You may not use this file except in compliance with the License.
30 30 .\"
31 31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 32 .\" or http://www.opensolaris.org/os/licensing.
33 33 .\" See the License for the specific language governing permissions
34 34 .\" and limitations under the License.
35 35 .\"
36 36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
38 38 .\" If applicable, add the following below this CDDL HEADER, with the
39 39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 41 .\"
42 42 .\"
43 43 .\" Copyright 1989 AT&T
44 44 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved
45 45 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
46 46 .\" Copyright 2013 Nexenta Systems, Inc. All rights reserved.
47 47 .\"
48 -.TH CP 1 "Apr 15, 2013"
48 +.TH CP 1 "May 17, 2020"
49 49 .SH NAME
50 50 cp \- copy files
51 51 .SH SYNOPSIS
52 -.LP
53 52 .nf
54 53 \fB/usr/bin/cp\fR [\fB-afip@/\fR] \fIsource_file\fR \fItarget_file\fR
55 54 .fi
56 55
57 56 .LP
58 57 .nf
59 58 \fB/usr/bin/cp\fR [\fB-afip@/\fR] \fIsource_file\fR... \fItarget\fR
60 59 .fi
61 60
62 61 .LP
63 62 .nf
64 63 \fB/usr/bin/cp\fR [\fB-r\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR]] [\fB-afip@/\fR] \fIsource_dir\fR... \fItarget\fR
65 64 .fi
66 65
67 66 .LP
68 67 .nf
69 68 \fB/usr/bin/cp\fR [\fB-R\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR]] [\fB-afip@/\fR] \fIsource_dir\fR... \fItarget\fR
70 69 .fi
71 70
72 71 .LP
73 72 .nf
74 73 \fB/usr/xpg4/bin/cp\fR [\fB-afip@/\fR] \fIsource_file\fR \fItarget_file\fR
75 74 .fi
76 75
77 76 .LP
78 77 .nf
79 78 \fB/usr/xpg4/bin/cp\fR [\fB-afip@/\fR] \fIsource_file\fR... \fItarget\fR
80 79 .fi
81 80
82 81 .LP
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
83 82 .nf
84 83 \fB/usr/xpg4/bin/cp\fR [\fB-r\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR]] [\fB-afip@/\fR] \fIsource_dir\fR... \fItarget\fR
85 84 .fi
86 85
87 86 .LP
88 87 .nf
89 88 \fB/usr/xpg4/bin/cp\fR [\fB-R\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR]] [\fB-afip@/\fR] \fIsource_dir\fR... \fItarget\fR
90 89 .fi
91 90
92 91 .SH DESCRIPTION
93 -.sp
94 -.LP
95 92 In the first synopsis form, neither \fIsource_file\fR nor \fItarget_file\fR are
96 93 directory files, nor can they have the same name. The \fBcp\fR utility copies
97 94 the contents of \fIsource_file\fR to the destination path named by
98 95 \fItarget_file\fR. If \fItarget_file\fR exists, \fBcp\fR overwrites its
99 96 contents, but the mode (and \fBACL\fR if applicable), owner, and group
100 97 associated with it are not changed. The last modification time of
101 98 \fItarget_file\fR and the last access time of \fIsource_file\fR are set to the
102 99 time the copy was made. If \fItarget_file\fR does not exist, \fBcp\fR creates a
103 100 new file named \fItarget_file\fR that has the same mode as \fIsource_file\fR
104 101 except that the sticky bit is not set unless the user is super-user. In this
105 102 case, the owner and group of \fItarget_file\fR are those of the user, unless
106 103 the setgid bit is set on the directory containing the newly created file. If
107 104 the directory's setgid bit is set, the newly created file has the group of the
108 105 containing directory rather than of the creating user. If \fItarget_file\fR is
109 106 a link to another file, \fBcp\fR overwrites the link destination with the
110 107 contents of \fIsource_file\fR; the link(s) from \fItarget_file\fR remains.
111 108 .sp
112 109 .LP
113 110 In the second synopsis form, one or more \fIsource_file\fRs are copied to the
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
114 111 directory specified by \fItarget\fR. It is an error if any \fIsource_file\fR is
115 112 a file of type directory, if \fItarget\fR either does not exist or is not a
116 113 directory.
117 114 .sp
118 115 .LP
119 116 In the third or fourth synopsis forms, one or more directories specified by
120 117 \fIsource_dir\fR are copied to the directory specified by \fItarget\fR. Either
121 118 the \fB-r\fR or \fB-R\fR must be specified. For each \fIsource_dir\fR, \fBcp\fR
122 119 copies all files and subdirectories.
123 120 .SH OPTIONS
124 -.sp
125 -.LP
126 121 The following options are supported for both \fB/usr/bin/cp\fR and
127 122 \fB/usr/xpg4/bin/cp\fR:
128 123 .sp
129 124 .ne 2
130 125 .na
131 126 \fB\fB-a\fR\fR
132 127 .ad
133 128 .RS 6n
134 129 Archive mode. Same as -RpP.
135 130 .RE
136 131
137 132 .sp
138 133 .ne 2
139 134 .na
140 135 \fB\fB-f\fR\fR
141 136 .ad
142 137 .RS 6n
143 138 Unlink. If a file descriptor for a destination file cannot be obtained, this
144 139 option attempts to unlink the destination file and proceed.
145 140 .RE
146 141
147 142 .sp
148 143 .ne 2
149 144 .na
150 145 \fB\fB-H\fR\fR
151 146 .ad
152 147 .RS 6n
153 148 Takes actions based on the type and contents of the file referenced by any
154 149 symbolic link specified as a \fIsource_file\fR operand.
155 150 .sp
156 151 If the \fIsource_file\fR operand is a symbolic link, then \fBcp\fR copies the
157 152 file referenced by the symbolic link for the \fIsource_file\fR operand. All
158 153 other symbolic links encountered during traversal of a file hierarchy are
159 154 preserved.
160 155 .RE
161 156
162 157 .sp
163 158 .ne 2
164 159 .na
165 160 \fB\fB-i\fR\fR
166 161 .ad
167 162 .RS 6n
168 163 Interactive. \fBcp\fR prompts for confirmation whenever the copy would
169 164 overwrite an existing \fItarget\fR. An affirmative response means that the copy
170 165 should proceed. Any other answer prevents \fBcp\fR from overwriting
171 166 \fItarget\fR.
172 167 .RE
173 168
174 169 .sp
175 170 .ne 2
176 171 .na
177 172 \fB\fB-L\fR\fR
178 173 .ad
179 174 .RS 6n
180 175 Takes actions based on the type and contents of the file referenced by any
181 176 symbolic link specified as a \fIsource_file\fR operand or any symbolic links
182 177 encountered during traversal of a file hierarchy.
183 178 .sp
184 179 Copies files referenced by symbolic links. Symbolic links encountered during
185 180 traversal of a file hierarchy are not preserved.
186 181 .RE
187 182
188 183 .sp
189 184 .ne 2
190 185 .na
191 186 \fB\fB-p\fR\fR
192 187 .ad
193 188 .RS 6n
194 189 Preserve. The \fBcp\fR utility duplicates not only the contents of
195 190 \fIsource_file\fR, but also attempts to preserve its ACL, access and
196 191 modification times, extended attributes, extended system attributes, file mode,
197 192 and owner and group ids.
198 193 .sp
199 194 If \fBcp\fR is unable to preserve the access and modification times, extended
200 195 attributes, or the file mode, \fBcp\fR does not consider it a failure. If
201 196 \fBcp\fR is unable to preserve the owner and group id, the copy does not fail,
202 197 but \fBcp\fR silently clears the \fBS_ISUID\fR and \fBS_ISGID\fR bits from the
203 198 file mode of the target. The copy fails if \fBcp\fR is unable to clear these
204 199 bits. If \fBcp\fR is unable to preserve the ACL or extended system attributes,
205 200 the copy fails. If the copy fails, then a diagnostic message is written to
206 201 \fBstderr\fR and (after processing any remaining operands) \fBcp\fR exits with
207 202 a \fBnon-zero\fR exit status.
208 203 .RE
209 204
210 205 .sp
211 206 .ne 2
212 207 .na
213 208 \fB\fB-P\fR\fR
214 209 .ad
215 210 .RS 6n
216 211 Takes actions on any symbolic link specified as a \fIsource_file\fR operand or
217 212 any symbolic link encountered during traversal of a file hierarchy.
218 213 .sp
219 214 Copies symbolic links. Symbolic links encountered during traversal of a file
220 215 hierarchy are preserved.
221 216 .RE
222 217
223 218 .sp
224 219 .ne 2
225 220 .na
226 221 \fB\fB-r\fR\fR
227 222 .ad
228 223 .RS 6n
229 224 Recursive. \fBcp\fR copies the directory and all its files, including any
230 225 subdirectories and their files to \fItarget\fR. Unless the \fB-H\fR, \fB-L\fR,
231 226 or \fB-P\fR option is specified, the \fB-L\fR option is used as the default
232 227 mode.
233 228 .RE
234 229
235 230 .sp
236 231 .ne 2
237 232 .na
238 233 \fB\fB-R\fR\fR
239 234 .ad
240 235 .RS 6n
241 236 Same as \fB-r\fR, except pipes are replicated, not read from.
242 237 .RE
243 238
244 239 .sp
245 240 .ne 2
246 241 .na
247 242 \fB\fB-@\fR\fR
248 243 .ad
249 244 .RS 6n
250 245 Preserves extended attributes. \fBcp\fR attempts to copy all of the source
251 246 file's extended attributes along with the file data to the destination file.
252 247 .RE
253 248
254 249 .sp
255 250 .ne 2
256 251 .na
257 252 \fB\fB-/\fR\fR
258 253 .ad
259 254 .RS 6n
260 255 Preserves extended attributes and extended system attributes. Along with the
261 256 file's data, the \fBcp\fR utility attempts to copy extended attributes and
262 257 extended system attributes from each source file, and extended system
263 258 attributes associated with extended attributes to the destination file. If
264 259 \fBcp\fR is unable to copy extended attributes or extended system attributes,
↓ open down ↓ |
129 lines elided |
↑ open up ↑ |
265 260 then a diagnostic message is written to \fBstderr\fR and (after processing any
266 261 remaining operands) exits with a \fBnon-zero\fR exit status.
267 262 .RE
268 263
269 264 .sp
270 265 .LP
271 266 Specifying more than one of the mutually-exclusive options \fB-H\fR, \fB-L\fR,
272 267 and \fB-P\fR is not considered an error. The last option specified determines
273 268 the behavior of the utility.
274 269 .SS "/usr/bin/cp"
275 -.sp
276 -.LP
277 270 If the \fB-p\fR option is specified with either the \fB-@\fR option or the
278 271 \fB-/\fR option, \fB/usr/bin/cp\fR behaves as follows
279 272 .RS +4
280 273 .TP
281 274 .ie t \(bu
282 275 .el o
283 276 When both \fB-p\fR and \fB-@\fR are specified in any order, the copy fails if
284 277 extended attributes cannot be copied.
285 278 .RE
286 279 .RS +4
287 280 .TP
288 281 .ie t \(bu
289 282 .el o
290 283 When both \fB-p\fR and \fB-/\fR are specified in any order, the copy fails if
291 284 extended system attributes cannot be copied.
292 285 .RE
293 286 .SS "/usr/xpg4/bin/cp"
294 -.sp
295 -.LP
296 287 If the \fB-p\fR option is specified with either the \fB-@\fR option or the
297 -\fB-/\fR option, /\fBusr/xpg4/bin/cp\fR behaves as follows:
288 +\fB-/\fR option, \fB/usr/xpg4/bin/cp\fR behaves as follows:
298 289 .RS +4
299 290 .TP
300 291 .ie t \(bu
301 292 .el o
302 293 When both \fB-p\fR and \fB-@\fR are specified, the last option specified
303 294 determines whether the copy fails if extended attributes cannot be preserved.
304 295 .RE
305 296 .RS +4
306 297 .TP
307 298 .ie t \(bu
308 299 .el o
309 300 When both \fB-p\fR and \fB-/\fR are specified, the last option specified
310 301 determines whether the copy fails if extended system attributes cannot be
311 302 preserved.
312 303 .RE
313 304 .SH OPERANDS
314 -.sp
315 -.LP
316 305 The following operands are supported:
317 306 .sp
318 307 .ne 2
319 308 .na
320 309 \fB\fIsource_file\fR\fR
321 310 .ad
322 311 .RS 15n
323 312 A pathname of a regular file to be copied.
324 313 .RE
325 314
326 315 .sp
327 316 .ne 2
328 317 .na
329 318 \fB\fIsource_dir\fR\fR
330 319 .ad
331 320 .RS 15n
332 321 A pathname of a directory to be copied.
333 322 .RE
334 323
335 324 .sp
336 325 .ne 2
337 326 .na
338 327 \fB\fItarget_file\fR\fR
339 328 .ad
340 329 .RS 15n
341 330 A pathname of an existing or non-existing file, used for the output when a
342 331 single file is copied.
343 332 .RE
344 333
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
345 334 .sp
346 335 .ne 2
347 336 .na
348 337 \fB\fItarget\fR\fR
349 338 .ad
350 339 .RS 15n
351 340 A pathname of a directory to contain the copied files.
352 341 .RE
353 342
354 343 .SH USAGE
355 -.sp
356 -.LP
357 344 See \fBlargefile\fR(5) for the description of the behavior of \fBcp\fR when
358 345 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
359 346 .SH EXAMPLES
360 -.LP
361 347 \fBExample 1 \fRCopying a File
362 348 .sp
363 349 .LP
364 350 The following example copies a file:
365 351
366 352 .sp
367 353 .in +2
368 354 .nf
369 355 example% cp goodies goodies.old
370 356
371 357 example% ls goodies*
372 358 goodies goodies.old
373 359 .fi
374 360 .in -2
375 361 .sp
376 362
377 363 .LP
378 364 \fBExample 2 \fRCopying a List of Files
379 365 .sp
380 366 .LP
381 367 The following example copies a list of files to a destination directory:
382 368
383 369 .sp
384 370 .in +2
385 371 .nf
386 372 example% cp ~/src/* /tmp
387 373 .fi
388 374 .in -2
389 375 .sp
390 376
391 377 .LP
392 378 \fBExample 3 \fRCopying a Directory
393 379 .sp
394 380 .LP
395 381 The following example copies a directory, first to a new, and then to an
396 382 existing destination directory
397 383
398 384 .sp
399 385 .in +2
400 386 .nf
401 387 example% ls ~/bkup
402 388 /usr/example/fred/bkup not found
403 389
404 390 example% cp \fB-r\fR ~/src ~/bkup
405 391
406 392 example% ls \fB-R\fR ~/bkup
407 393 x.c y.c z.sh
408 394
409 395 example% cp \fB-r\fR ~/src ~/bkup
410 396
411 397 example% ls \fB-R\fR ~/bkup
412 398 src x.c y.c z.sh
413 399 src:
414 400 x.c y.c z.s
415 401 .fi
416 402 .in -2
417 403 .sp
418 404
419 405 .LP
420 406 \fBExample 4 \fRCopying Extended File System Attributes
421 407 .sp
422 408 .LP
423 409 The following example copies extended file system attributes:
424 410
425 411 .sp
426 412 .in +2
427 413 .nf
428 414 $ ls -/ c file1
429 415 -rw-r--r-- 1 foo staff 0 Oct 29 20:04 file1
430 416 {AH-----m--}
431 417
432 418 $ cp -/ file1 file2
433 419 $ ls -/c file2
434 420 -rw-r--r-- 1 foo staff 0 Oct 29 20:17 file2
435 421 {AH-----m--}
436 422 .fi
437 423 .in -2
438 424 .sp
439 425
440 426 .LP
441 427 \fBExample 5 \fRFailing to Copy Extended System Attributes
442 428 .sp
443 429 .LP
444 430 The following example fails to copy extended system attributes:
445 431
446 432 .sp
447 433 .in +2
448 434 .nf
449 435 $ ls -/c file1
450 436 -rw-r--r-- 1 foo staff 0 Oct 29 20:04 file1
451 437 {AH-----m--}
452 438
453 439 $ cp -/ file1 /tmp
454 440 cp: Failed to copy extended system attributes from file1 to /tmp/file1
↓ open down ↓ |
84 lines elided |
↑ open up ↑ |
455 441
456 442
457 443 $ ls -/c /tmp/file1
458 444 -rw-r--r-- 1 foo staff 0 Oct 29 20:09 /tmp/file1
459 445 {}
460 446 .fi
461 447 .in -2
462 448 .sp
463 449
464 450 .SH ENVIRONMENT VARIABLES
465 -.sp
466 -.LP
467 451 See \fBenviron\fR(5) for descriptions of the following environment variables
468 452 that affect the execution of \fBcp\fR: \fBLANG\fR, \fBLC_ALL\fR,
469 453 \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
470 454 .sp
471 455 .LP
472 456 Affirmative responses are processed using the extended regular expression
473 457 defined for the \fByesexpr\fR keyword in the \fBLC_MESSAGES\fR category of the
474 458 user's locale. The locale specified in the \fBLC_COLLATE\fR category defines
475 459 the behavior of ranges, equivalence classes, and multi-character collating
476 460 elements used in the expression defined for \fByesexpr\fR. The locale specified
477 461 in \fBLC_CTYPE\fR determines the locale for interpretation of sequences of
478 462 bytes of text data a characters, the behavior of character classes used in the
479 463 expression defined for the \fByesexpr\fR. See \fBlocale\fR(5).
480 464 .SH EXIT STATUS
481 -.sp
482 -.LP
483 465 The following exit values are returned:
484 466 .sp
485 467 .ne 2
486 468 .na
487 469 \fB\fB0\fR\fR
488 470 .ad
489 471 .RS 6n
490 472 All files were copied successfully.
491 473 .RE
492 474
493 475 .sp
494 476 .ne 2
495 477 .na
496 478 \fB\fB>0\fR\fR
497 479 .ad
498 480 .RS 6n
499 481 An error occurred.
500 482 .RE
501 483
502 484 .SH ATTRIBUTES
503 -.sp
504 -.LP
505 485 See \fBattributes\fR(5) for descriptions of the following attributes:
506 486 .SS "/usr/bin/cp"
507 -.sp
508 -
509 -.sp
510 487 .TS
511 488 box;
512 489 c | c
513 490 l | l .
514 491 ATTRIBUTE TYPE ATTRIBUTE VALUE
515 492 _
516 493 CSI Enabled
517 494 _
518 495 Interface Stability Committed
519 496 .TE
520 497
521 498 .SS "/usr/xpg4/bin/cp"
522 -.sp
523 -
524 -.sp
525 499 .TS
526 500 box;
527 501 c | c
528 502 l | l .
529 503 ATTRIBUTE TYPE ATTRIBUTE VALUE
530 504 _
531 505 CSI Enabled
532 506 _
533 507 Interface Stability Committed
534 508 .TE
535 509
536 510 .SH SEE ALSO
537 -.sp
538 -.LP
539 511 \fBchmod\fR(1), \fBchown\fR(1), \fBsetfacl\fR(1), \fButime\fR(2),
540 512 \fBfgetattr\fR(3C), \fBattributes\fR(5), \fBenviron\fR(5), \fBfsattr\fR(5),
541 513 \fBlargefile\fR(5), \fBlocale\fR(5), \fBstandards\fR(5)
542 514 .SH NOTES
543 -.sp
544 -.LP
545 515 The permission modes of the source file are preserved in the copy.
546 516 .sp
547 517 .LP
548 518 A \fB--\fR permits the user to mark the end of any command line options
549 519 explicitly, thus allowing \fBcp\fR to recognize filename arguments that begin
550 520 with a \fB-\fR.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX