Name

cp - Copy a file

Syntax

cp file… [ target ]

Description

Cp copies one or more files to another file or directory. The source file may be in another directory, in which case a path must be given.

If the target is a directory, the source file(s) are copied to files in the directory using their original filenames.

If the destination file does not exist, it is created, and the contents of the source files are copied.

If a source file is given, but no target file, the current working directory is assumed as the target area, preserving the original filename, though cp refuses to copy a file to itself.

Example:

cp $/usr/jholt/rocks garbage

This copies “rocks” from $/usr/jholt to the file “garbage” in the current working directory. If “garbage” was omitted, the original filename “rocks” would have been used.

See Also

add(C), cat(C), mv(C), rcp(NET)