Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ cp(1) — SunOS 5.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(1)

cpio(1)

rm(1)

cp(1)

NAME

cp − copy files

SYNOPSIS

cp [ −i ] [ −p ] [ −r ] [ filename ... ] target

AVAILABILITY

SUNWcsu

DESCRIPTION

The cp command copies filename to target. filename and target cannot have the same name.  Be careful 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. 

If filename is a directory, target must be a directory in the same physical file system.  target and filename do not have to share the same parent directory. 

If filename 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 mode as filename 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 mode, owner, and group associated with it are not changed.  The last modification time of target and the last access time of filename 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 mode is created in the target directory; the owner and the group are those of the user making the copy. 

OPTIONS

−i Interactive.  cp will prompt for confirmation whenever the copy would overwrite an existing target. A y answer means that the copy should proceed.  Any other answer prevents cp from overwriting target.

−p Preserve.  cp will duplicate not only the contents of filename, but also preserves the modification time and permission modes.

−r If filename is a directory, cp will copy the directory and all its files, including any subdirectories and their files; target must be a directory. 

EXAMPLES

To copy a file:

example% cp goodies goodies.old
example% ls goodies∗
goodies goodies.old

To copy a directory, first to a new, and then to an existing destination directory:

example% ls ~/bkup
/usr/example/fred/bkup not found
example% cp −r ~/src ~/bkup
example% ls −R ~/bkup
x.c y.c z.sh
example% cp −r ~/src ~/bkup
example% ls −R ~/bkup
src x.c y.c z.sh
src:
x.c y.c z.sh

To copy a list of files to a destination directory:

example% cp ~/src/∗   /tmp

SEE ALSO

chmod(1), cpio(1), rm(1)

NOTES

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. 

SunOS 5.1  —  Last change: 26 Sep 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026