Reference: cp
Author: Daniel Gilly & the Staff of O'Reilly & Associates
Date: 1998-08-06T21:52:24Z

#

| Chapter 2 UNIX Commands |

## cp

    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.

### Options

-i

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

-p

  Preserve the modification time and permission modes for the copied file. (Normally cp supplies the permissions of the invoking user.)

-r

  Recursively copy a directory, its files, and its subdirectories to a destination `directory`, duplicating the tree structure. (This option is used with the second command-line format when at least one of the source `file` arguments is a directory.)

### Example

Copy two files to their parent directory (keep the same names):

>     cp outline memo ..

Reference: compress |  | Reference: cpio