convert to letter format
[unix-history] / usr / src / bin / cp / cp.1
CommitLineData
a783899b
KB
1.\" Copyright (c) 1989 The Regents of the University of California.
2.\" All rights reserved.
c4c58dfe 3.\"
a783899b
KB
4.\" Redistribution and use in source and binary forms are permitted
5.\" provided that the above copyright notice and this paragraph are
6.\" duplicated in all such forms and that any documentation,
7.\" advertising materials, and other materials related to such
8.\" distribution and use acknowledge that the software was developed
9.\" by the University of California, Berkeley. The name of the
10.\" University may not be used to endorse or promote products derived
11.\" from this software without specific prior written permission.
12.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15.\"
16.\" @(#)cp.1 6.4 (Berkeley) %G%
c4c58dfe 17.\"
91e4161e 18.TH CP 1 ""
c4c58dfe
KM
19.UC 4
20.SH NAME
a783899b 21cp - copy files
c4c58dfe 22.SH SYNOPSIS
a783899b
KB
23\fBcp [ \fI-fhip\fB ] source_file target_file
24.sp
25\fBcp [ \fI-fhipr\fB ] source_file ... target_directory
26.ft R
c4c58dfe 27.SH DESCRIPTION
a783899b 28The
ec6dcb7a 29.I cp
a783899b
KB
30utility copies
31.I source_file
32to
33.I target_file
34or, in the second form, one or more
35.IR source_file s
36are copied into the target
37.IR target_directory ,
38retaining their original filenames.
39If
40.I cp
41detects an attempt to copy a file to itself, the copy shall fail.
42For each destination file that already exists, its contents are
43overwritten if permissions allow, but its mode, user ID, and group
44ID are unchanged.
45Otherwise, the mode of the
46.I source_file
47is used as modified by the file mode creation mask.
48Appropriate permissions are required for file creation or overwriting.
c4c58dfe 49.PP
a783899b
KB
50The following options are available:
51.TP
52.I -h
53Forces
c4c58dfe 54.I cp
a783899b
KB
55to follow symbolic links.
56.TP
57.I -f
58Force existing destination pathnames to be removed before copying,
59without prompting for confirmation.
60.TP
61.I -i
62Causes
c4c58dfe 63.I cp
a783899b
KB
64to write a prompt to standard error before copying a file that would
65overwrite an existing file.
66If the response from the standard input begins with the character ``y'',
67the file is copied if permissions allow the copy.
68.TP
69.I -p
70Causes
04d3a81e 71.I cp
a783899b
KB
72to preserve in the copy as many of the modification time, access time,
73file mode, user ID, and group ID as allowed by permissions.
74.TP
75.I -r
76If
77.I source_file
78designates a directory,
79.I cp
80copies the directory and the entire subtree connected at that point.
81This option also causes symbolic links to be copied, rather than
82indirected through, and for
0493752e 83.I cp
a783899b
KB
84to create special files rather than copying them as normal files.
85.PP
86The
87.I -i
88option is ignored if the
89.I -f
90option is specified.
91.PP
92Symbolic links are followed unless the
93.I -r
94option is specified, in which case the link itself is copied.
95.PP
96.I Cp
97exits 0 on success, >0 if an error occurred.
c4c58dfe 98.SH "SEE ALSO"
a783899b 99mv(1), rcp(1), umask(2)