|
|
1.1 root 1: .\" Copyright (c) 1989, 1990 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" Redistribution and use in source and binary forms are permitted provided
5: .\" that: (1) source distributions retain this entire copyright notice and
6: .\" comment, and (2) distributions including binaries display the following
7: .\" acknowledgement: ``This product includes software developed by the
8: .\" University of California, Berkeley and its contributors'' in the
9: .\" documentation or other materials provided with the distribution and in
10: .\" all advertising materials mentioning features or use of this software.
11: .\" Neither the name of the University nor the names of its contributors may
12: .\" be used to endorse or promote products derived from this software without
13: .\" specific prior written permission.
14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17: .\"
18: .\" @(#)cp.1 6.11 (Berkeley) 7/24/90
19: .\"
20: .Dd July 24, 1990
21: .Dt CP 1
22: .Os BSD 4
23: .Sh NAME
24: .Nm cp
25: .Nd copy files
26: .Sh SYNOPSIS
27: .Nm cp
28: .Op Fl Rfhip
29: .Ar source_file target_file
30: .Nm cp
31: .Op Fl Rfhip
32: .Ar source_file ... target_directory
33: .Sh DESCRIPTION
34: In the first synopsis form, the
35: .Nm cp
36: utility copies the contents of the
37: .Ar source_file
38: to the
39: .Ar target_file .
40: In the second synopsis form,
41: the contents of each named
42: .Ar source_file
43: is copied to the destination
44: .Ar target_directory .
45: The names of the files themselves are not changed.
46: If
47: .Nm cp
48: detects an attempt to copy a file to itself, the copy will fail.
49: .Pp
50: The following options are available:
51: .Tw Ds
52: .Tp Fl f
53: For each existing destination pathname, remove it and
54: create a new file, without prompting for confirmation
55: regardless of its permissions.
56: (The
57: .Fl i
58: option is ignored if the
59: .Fl f
60: option is specified.)
61: .Tp Fl h
62: Forces
63: .Nm cp
64: to follow symbolic links.
65: Provided for the
66: .Fl R
67: option which does not follow symbolic links by default.
68: .Tp Fl i
69: Causes
70: .Nm cp
71: to write a prompt to standard error before copying a file that would
72: overwrite an existing file.
73: If the response from the standard input begins with the character
74: .Sq Li y ,
75: the file is copied if permissions allow the copy.
76: .Tp Fl p
77: Causes
78: .Nm cp
79: to preserve in the copy as many of the modification time, access time,
80: file mode, user ID, and group ID as allowed by permissions.
81: .Pp
82: If the user ID and group ID cannot be preserved, no error message
83: is displayed and the exit value is not altered.
84: .Pp
85: If the source file has its set user ID bit on and the user ID cannot
86: be preserved, the set user ID bit is not preserved
87: in the copy's permissions.
88: If the source file has its set group ID bit on and the group ID cannot
89: be preserved, the set group ID bit is not preserved
90: in the copy's permissions.
91: If the source file has both the set user ID and set group ID bits
92: on and either the user ID or group ID cannot be preserved, neither
93: the set user ID or set group ID bits are preserved in the copy's
94: permissions.
95: .Tp Fl R
96: If
97: .Ar source_file
98: designates a directory,
99: .Nm cp
100: copies the directory and the entire subtree connected at that point.
101: This option also causes symbolic links to be copied, rather than
102: indirected through, and for
103: .Nm cp
104: to create special files rather than copying them as normal files.
105: Created directories have the same mode as the corresponding source
106: directory, unmodified by the process' umask.
107: .Tp
108: .Pp
109: For each destination file that already exists, its contents are
110: overwritten if permissions allow, but its mode, user ID, and group
111: ID are unchanged.
112: .Pp
113: If the destination file does not exist, the mode of the source file is
114: used as modified by the file mode creation mask
115: .Pf \&( Ic umask ,
116: see
117: .Xr csh 1 ) .
118: If the source file has its set user ID bit on, that bit is removed
119: unless both the source file and the destination file are owned by the
120: same user.
121: If the source file has its set group ID bit on, that bit is removed
122: unless both the source file and the destination file are in the same
123: group and the user is a member of that group.
124: If both the set user ID and set group ID bits are set, all of the above
125: conditions must be fulfilled or both bits are removed.
126: .Pp
127: Appropriate permissions are required for file creation or overwriting.
128: .Pp
129: Symbolic links are followed unless the
130: .Fl R
131: option is specified, in which case the link itself is copied.
132: .Pp
133: .Nm Cp
134: exits 0 on success, >0 if an error occurred.
135: .Sh SEE ALSO
136: .Xr mv 1 ,
137: .Xr rcp 1 ,
138: .Xr umask 2 ,
139: .Xr csh 1
140: .Sh HISTORY
141: The
142: .Nm cp
143: command appeared in Version 6 AT&T UNIX.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.