cp

NAME

cp - copy files

SYNOPSIS

cp [-fimpv] source_file target_file
cp [-fimpv] source_file ... target_directory
cp -R[-cfimpv] source_file ... target_directory
cp -r[-cfimpv] source_file ... target_directory

DESCRIPTION

In the first synopsis form, the cp(1) utility copies the contents of the source_file to the target_file. In the second, third, and fourth synopsis forms, the contents of each named source_file are copied to the destination target_directory. The names of the files are not changed. If cp(1) detects an attempt to copy a file to itself, the copy will fail.

OPTIONS

-c
This option suppresses the check for identical file identifier (inode) and device values on the source and destination files. This is to counteract a problem with some Windows network redirectors that provide random device and file identifier (ID) values. It should only be used when copying directories (with -r) on a networked drive. Otherwise, cp(1) may fail erroneously with the message:
cp : destdir/foo and srcdir/foo are identical (not copied)
-f
For each existing destination path name, remove it and create a new file, without prompting for confirmation regardless of its permissions.
-i
Inquire before copying a file that would overwrite an existing file. The cp(1) utility writes a prompt to the standard error output. If the response from the standard input begins with the character "y," the file copy is attempted.
-m
Preserve the modified and acces times from the src file. Like -p but only preserves the times.
-p
Preserve in the copy the following attributes, as permissions allow:

Modification time
Access time
File flags
File mode
User ID
Group ID

The following also apply to this option:

-R
Copy file hierarchies, including FIFOs; this may not be specified with the -r option.
-r
Copy file hierarchies but not including special files such as FIFOs; this may not be specified with the -R option.
-v
Display each filename to standard output as they are being copied.

The contents of each destination file that already exists are overwritten if permissions allow, but its mode, user ID, and group ID are unchanged.

In the second synopsis form, target_directory must exist unless there is only one named source_file, which is a directory, and the -R flag is specified.

If the destination file does not exist, the mode of the source file is used as modified by the file-mode creation mask.

Appropriate permissions are required for file creation or overwriting.

DIAGNOSTICS

The cp(1) utility exits 0 on success, >0 if an error occurred.

SEE ALSO

mv(1)

umask(1)