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