Name

cp

Synopsis

    cp [options] file1 file2
cp [options]files 
 directory

Copy file1 to file2, or copy one or more files to the same names under directory. If the destination is an existing file, the file is overwritten; if the destination is an existing directory, the file is copied into the directory (the directory is not overwritten). If one of the inputs is a directory, use the -r option.

Common Options

-f, --force

Remove existing files in the destination.

-i, --interactive

Prompt for confirmation (y for yes) before overwriting an existing file.

-p

Preserve the original file’s permissions, ownership, and timestamps in the new file.

-r, -R, --recursive

Copy directories recursively. Solaris -R replicates named pipes, instead of reading from them.

GNU/Linux and Mac OS X Options

-H

When used with -R, if a command-line argument is a symbolic link to a directory, recursively traverse the directory.

-L, --dereference

When used with -R, if any symbolic link points to a directory, recursively traverse the directory.

-P

When used with -R, do not follow any symbolic links. This is the default.

-v, --verbose

Before copying , print the name of each file.

Solaris Option

-@

Copy extended attributes (ACLs, etc.) along with normal attributes.

GNU/Linux Options

-a, --archive

Preserve attributes of original files where possible. The same as -dpR.

-b

Back up files that would otherwise be overwritten.

--backup[=backup-method]

Like -b, but accepts an additional specification controlling how the backup copy should be made. ...

Get Unix in a Nutshell, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.