make consistent with POSIX 1003.2, draft 10. Now have two recursive
[unix-history] / usr / src / bin / cp / cp.1
index ebdb349..afb838b 100644 (file)
-.\" Copyright (c) 1980 Regents of the University of California.
-.\" All rights reserved.  The Berkeley software License Agreement
-.\" specifies the terms and conditions for redistribution.
+.\" Copyright (c) 1989, 1990 The Regents of the University of California.
+.\" All rights reserved.
 .\"
 .\"
-.\"    @(#)cp.1        6.2 (Berkeley) %G%
+.\" %sccs.include.redist.man%
 .\"
 .\"
-.TH CP 1 ""
-.UC 4
-.SH NAME
-cp \- copy
-.SH SYNOPSIS
-.B cp
-[
-.B \-ip
-] file1 file2
-.PP
-.B cp
-[
-.B \-ipr
-] file ... directory
-.SH DESCRIPTION
-.I File1
-is copied onto
-.IR file2 .
-By default, the mode and owner of  
-.I file2
-are preserved if it already
-existed; otherwise the mode of the source file modified by the current
-.IR umask (2)
-is used.  The
-.B \-p
-option causes
-.I cp
-to attempt to preserve (duplicate) in its copies the modification
-times and modes of the source files, ignoring the present
-.IR umask .
-.PP
-In the second form, one or more
-.I files
-are copied into the
-.I directory
-with their original file-names.
-.PP
-.I Cp
-refuses to copy a file onto itself.
-.PP
-If the 
-.B \-i
-option is specified, 
-.I cp
-will prompt the user with the name of the file
-whenever the copy will cause an old file to be
-overwritten. An answer of 'y' will cause 
-.I cp
-to continue. Any other answer will prevent it
-from overwriting the file.
-.PP
-If the
-.B \-r
-option is specified and any of the source files are directories,
-.I cp
-copies each subtree rooted at that name; in this case
-the destination must be a directory.
-.SH "SEE ALSO"
-cat(1), mv(1), rcp(1C)
+.\"     @(#)cp.1       6.10 (Berkeley) %G%
+.\"
+.Dd 
+.Dt CP 1
+.Os BSD 4
+.Sh NAME
+.Nm cp
+.Nd copy files
+.Sh SYNOPSIS
+.Nm cp
+.Op Fl fhip
+.Ar source_file target_file
+.br
+.Nm cp
+.Op Fl Rfhip
+.Ar source_file ... target_directory
+.Sh DESCRIPTION
+In the first synopsis form,
+.Nm cp
+utility copies the contents of the
+.Ar source_file
+to the
+.Ar target_file
+or, in the second synopsis form,
+the contents of each named
+.Ar source_file(s)
+is copied to the destination
+.Ar target_directory .
+The names of the files themselves are not changed.
+If
+.Nm cp
+detects an attempt to copy a file to itself, the copy will fail.
+The following options are available:
+.Tp Fl h
+Forces
+.Nm cp
+to follow symbolic links.
+Provided for the
+.Fl R
+option which does not follow symbolic links by default.
+.Tp Fl f
+Turns off the
+.Fl i
+option.
+(The last
+.Fl f
+or
+.Fl i
+option overrides any previous specification of either option.)
+.Tp Fl i
+Causes
+.Nm cp
+to write a prompt to standard error before copying a file that would
+overwrite an existing file.
+If the response from the standard input begins with the character ``y'',
+the file is copied if permissions allow.
+(The last
+.Fl f
+or
+.Fl i
+option overrides any previous specification of either option.)
+.Tp Fl p
+Causes
+.Nm cp
+to preserve in the copy as many of the modification time, access time,
+.\" and file mode as allowed by permissions.
+file mode, user ID, and group ID as allowed by permissions.
+.Pp
+If the user ID and group ID cannot be preserved, no error message
+is displayed and the exit value is not altered.
+.Pp
+If the source file is set user ID or set group ID, and either the user
+ID or the group ID cannot be preserved, the set user ID and set group
+ID bits are not preserved in the copy's permissions.
+.Tp Fl R
+If
+.Ar source_file
+designates a directory,
+.Nm cp
+copies the directory and the entire subtree connected at that point.
+Special file types, such as symbolic links and block and character
+devices, are recreated instead of being copied.
+Created directories have the same mode as the corresponding source
+directory, unmodified by the process' file mode creation mask (umask).
+.Tp Fl r
+The
+.Fl r
+option is identical to the
+.Fl R
+option with the exception that it does not treat special files
+differently from regular files.
+Symbolic links are always followed.
+This option has been deprecated.
+.Tp
+.Pp
+For each destination file that already exists, its contents are
+overwritten if permissions allow, but
+.Nm cp
+will not change its mode, user ID, or group ID.
+However, if the file is not being copied by the super-user,
+writing the file may clear the set user ID or set group ID
+permission bits.
+.Pp
+If the destination file does not exist, the mode of the source file is
+used as modified by the file mode creation mask (umask).
+If the source file is either set user ID or set group ID, those
+bits are removed unless the source file and the destination
+file are owned by the same user and group.
+.Pp
+Appropriate permissions are required for file creation or overwriting.
+.Pp
+.Nm Cp
+exits 0 on success, >0 if an error occurred.
+.Sh SEE ALSO
+.Xr mv 1 ,
+.Xr rcp 1 ,
+.Xr umask 2
+.Sh HISTORY
+The
+.Nm cp
+command appeared in Version 6 AT&T UNIX.