cp(1)


cp -- copy files

Synopsis

/u95/bin/cp [-r | -R] [-f] [-i] [-p] [-e extent_opt] file1 [file2 ... ] target

Description

The cp command copies filen to target. filen and target may not have the same name. (Care must be taken when using sh(1) metacharacters.) If target is not a directory, only one file may be specified before it; if it is a directory, more than one file may be specified. If target does not exist, cp creates a file named target. If target exists and is not a directory, its contents are overwritten. If target is a directory, the file(s) are copied to that directory.

The following options are recognized:


-i
cp will prompt for confirmation whenever the copy would overwrite an existing target. An affirmative response means that the copy should proceed (the affirmative response is locale dependent: ``y'' in the C locale, see LANG on environ(5)). Any other answer prevents cp from overwriting target. The -i option remains in effect even if the standard input is not a terminal.

-p
The ACL and permission bits of the target will be that of the source. Otherwise, the existing target retains its ACL and permission bits. The -p option causes the owner and group to be copied from the source file to the target.

-f
cp will attempt to overwrite an existing target. If a file descriptor for target cannot be obtained, cp will attempt to unlink target and proceed. See ``Notices'' below.

-r
(if filen is a directory) Copy the directory and all its files, including any subdirectories and their files. (target must be a directory.) -r is multithreaded and uses the enhanced nftw(3C) (walk a file tree). See ``Notices'' below.

-R
Copy a file hierarchy in the same fashion as -r. However, instead of copying special files (device files, FIFOs, or symbolic links) by copying their contents, create a target file with the same file type as filen. Normal files are copied in the same fashion as for -r. -R is multithreaded and uses the enhanced nftw (walk a file tree). See ``Notices'' below.

-e extent_opt
Specify how to handle a vxfs file that has extent attribute information. Extent attributes include reserved space, a fixed extent size, and extent alignment. It may not be possible to preserve the information if the destination file system does not support extent attributes, has a different block size than the source file system, or lacks free extents appropriate to satisfy the extent attribute requirements. Valid values for extent_opt are:

warn
Issue a warning message if extent attribute information cannot be kept (default).

force
Fail the copy if extent attribute information cannot be kept.

ignore
Ignore extent attribute information entirely.
If filen is a file and target is a link to another file with links, the other links remain and target becomes a new file.

If target does not exist, cp creates a new file named target which has the same ACL and access permissions as filen except that the sticky bit is not set unless the user is a privileged user; the owner and group of target are those of the user.

If target is a file, its contents are overwritten, but the ACL, access permissions, owner, and group associated with it are not changed.

The last modification time of target and the last access time of filen are set to the time the copy was made.

If target is a directory, then for each file named, a new file with the same ACL and access permissions is created in the target directory; the owner and the group are those of the user making the copy. If target has a default ACL, it is not inherited by the new files.

ACLs are supported only if the target file system is of type sfs or type vxfs.

Environment variables

If POSIX2 is set, cp -iR prompts for confirmation only for files in the target path, not for directories.

Files


/usr/lib/locale/locale/LC_MESSAGES/uxcore.abi
language-specific message file (see LANG on environ(5)).

References

chmod(1), cpio(1), getacl(1), ln(1), mv(1), rm(1), setacl(1)

Notices

A -- permits the user to mark the end of any command line options explicitly, thus allowing cp to recognize filename arguments that begin with a -. If a -- and a - both appear on the same command line, the second will be interpreted as a filename.

cp without the -R options usually hangs if file is a pipe.

It is not considered an error if more than one of the -f or -i options are specified. The last option specified will determine cp's behavior.

The algorithm used to efficiently distribute the tree walking among various threads may affect the order in which files and directories are copied. This order may not match the hierarchy of the original input tree. The result, however, will match the source. Issuing a BREAK to the command while it is executing will yield a partially completed tree where files and directories may appear to have been copied arbitrarily. No particular order is guaranteed. Because they are not dependent on any particular order for populating the tree, cp -r and cp -R execute much more quickly than previous versions.

This command has been updated to handle files greater than 2GB.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 02 June 2005