Commit | Line | Data |
---|---|---|
b5dc1377 | 1 | .\" Copyright (c) 1989, 1990 The Regents of the University of California. |
a783899b | 2 | .\" All rights reserved. |
c4c58dfe | 3 | .\" |
27c71911 | 4 | .\" %sccs.include.redist.man% |
a783899b | 5 | .\" |
3c3c3fc0 | 6 | .\" @(#)cp.1 6.10 (Berkeley) %G% |
c4c58dfe | 7 | .\" |
b5dc1377 CL |
8 | .Dd |
9 | .Dt CP 1 | |
10 | .Os BSD 4 | |
11 | .Sh NAME | |
12 | .Nm cp | |
13 | .Nd copy files | |
14 | .Sh SYNOPSIS | |
15 | .Nm cp | |
16 | .Op Fl fhip | |
17 | .Ar source_file target_file | |
18 | .br | |
19 | .Nm cp | |
3c3c3fc0 | 20 | .Op Fl Rfhip |
b5dc1377 CL |
21 | .Ar source_file ... target_directory |
22 | .Sh DESCRIPTION | |
23 | In the first synopsis form, | |
24 | .Nm cp | |
25 | utility copies the contents of the | |
26 | .Ar source_file | |
27 | to the | |
28 | .Ar target_file | |
29 | or, in the second synopsis form, | |
30 | the contents of each named | |
31 | .Ar source_file(s) | |
32 | is copied to the destination | |
33 | .Ar target_directory . | |
34 | The names of the files themselves are not changed. | |
a783899b | 35 | If |
b5dc1377 | 36 | .Nm cp |
24e5a125 | 37 | detects an attempt to copy a file to itself, the copy will fail. |
a783899b | 38 | The following options are available: |
b5dc1377 | 39 | .Tp Fl h |
a783899b | 40 | Forces |
b5dc1377 | 41 | .Nm cp |
a783899b | 42 | to follow symbolic links. |
24e5a125 | 43 | Provided for the |
3c3c3fc0 | 44 | .Fl R |
24e5a125 | 45 | option which does not follow symbolic links by default. |
b5dc1377 | 46 | .Tp Fl f |
3c3c3fc0 | 47 | Turns off the |
b5dc1377 | 48 | .Fl i |
3c3c3fc0 KB |
49 | option. |
50 | (The last | |
b5dc1377 | 51 | .Fl f |
3c3c3fc0 KB |
52 | or |
53 | .Fl i | |
54 | option overrides any previous specification of either option.) | |
b5dc1377 | 55 | .Tp Fl i |
a783899b | 56 | Causes |
b5dc1377 | 57 | .Nm cp |
a783899b KB |
58 | to write a prompt to standard error before copying a file that would |
59 | overwrite an existing file. | |
60 | If the response from the standard input begins with the character ``y'', | |
3c3c3fc0 KB |
61 | the file is copied if permissions allow. |
62 | (The last | |
63 | .Fl f | |
64 | or | |
65 | .Fl i | |
66 | option overrides any previous specification of either option.) | |
b5dc1377 | 67 | .Tp Fl p |
a783899b | 68 | Causes |
b5dc1377 | 69 | .Nm cp |
a783899b | 70 | to preserve in the copy as many of the modification time, access time, |
24e5a125 | 71 | .\" and file mode as allowed by permissions. |
a783899b | 72 | file mode, user ID, and group ID as allowed by permissions. |
b5dc1377 | 73 | .Pp |
c942f008 KB |
74 | If the user ID and group ID cannot be preserved, no error message |
75 | is displayed and the exit value is not altered. | |
b5dc1377 | 76 | .Pp |
3c3c3fc0 KB |
77 | If the source file is set user ID or set group ID, and either the user |
78 | ID or the group ID cannot be preserved, the set user ID and set group | |
79 | ID bits are not preserved in the copy's permissions. | |
80 | .Tp Fl R | |
a783899b | 81 | If |
b5dc1377 | 82 | .Ar source_file |
a783899b | 83 | designates a directory, |
b5dc1377 | 84 | .Nm cp |
a783899b | 85 | copies the directory and the entire subtree connected at that point. |
3c3c3fc0 KB |
86 | Special file types, such as symbolic links and block and character |
87 | devices, are recreated instead of being copied. | |
24e5a125 | 88 | Created directories have the same mode as the corresponding source |
3c3c3fc0 KB |
89 | directory, unmodified by the process' file mode creation mask (umask). |
90 | .Tp Fl r | |
91 | The | |
92 | .Fl r | |
93 | option is identical to the | |
94 | .Fl R | |
95 | option with the exception that it does not treat special files | |
96 | differently from regular files. | |
97 | Symbolic links are always followed. | |
98 | This option has been deprecated. | |
b5dc1377 CL |
99 | .Tp |
100 | .Pp | |
101 | For each destination file that already exists, its contents are | |
3c3c3fc0 KB |
102 | overwritten if permissions allow, but |
103 | .Nm cp | |
104 | will not change its mode, user ID, or group ID. | |
105 | However, if the file is not being copied by the super-user, | |
106 | writing the file may clear the set user ID or set group ID | |
107 | permission bits. | |
b5dc1377 CL |
108 | .Pp |
109 | If the destination file does not exist, the mode of the source file is | |
110 | used as modified by the file mode creation mask (umask). | |
3c3c3fc0 KB |
111 | If the source file is either set user ID or set group ID, those |
112 | bits are removed unless the source file and the destination | |
113 | file are owned by the same user and group. | |
b5dc1377 CL |
114 | .Pp |
115 | Appropriate permissions are required for file creation or overwriting. | |
116 | .Pp | |
b5dc1377 | 117 | .Nm Cp |
a783899b | 118 | exits 0 on success, >0 if an error occurred. |
b5dc1377 CL |
119 | .Sh SEE ALSO |
120 | .Xr mv 1 , | |
121 | .Xr rcp 1 , | |
122 | .Xr umask 2 | |
123 | .Sh HISTORY | |
124 | The | |
125 | .Nm cp | |
126 | command appeared in Version 6 AT&T UNIX. |