cp

copy files

Command


SYNOPSIS

cp [-cfimpv] file1 file2

cp [-cfimpv] file ... directory

cp -R [-cfimpv] source... directory

cp -r [-cfimpv] source... directory


DESCRIPTION

cp copies files to a target named by the last argument on its command line. If the target is an existing file, cp overwrites it; if it does not exist, cp creates it. If the target file already exists and does not have write permission, cp denies access and continues with the next copy.

If you specify more than two path names, the last path name (that is, the target) must be a directory. If the target is a directory, cp copies the sources into that directory with names given by the final component of the source path name.

Options

-c

prompts you to change the diskette if there is insufficient room to complete a copy operation. The parent directories must already exist on the new target diskette. This option has no effect on systems without floppy drives.

-f

attempts to replace files that do not have write permission.

-i

asks you if you want to overwrite an existing file, whether or not the file is read-only.

-m

sets the modify and access time of each destination file to that of the corresponding source file. Normally, cp sets the modification time of the destination file to the present.

-p

preserves the modify and access times (like -m) as well as the file mode, owner and group owner, if possible. The compression and archive attributes are never copied.

-R

reproduces the source trees. cp copies all files and subdirectories specified by source.... into directory, making careful arrangements to duplicate special files (FIFO, block special, character special).

-r

reproduces the source trees, but makes no allowances for special files (FIFO, block special, character special). Consequently, cp attempts to read from a device rather than duplicate the special file. This is similar to, but less useful than, the preferred -R.

-v

prints file names to standard output as they are being processed.


DIAGNOSTICS

Possible exit status values are:
0

Successful completion.

1

Failure due to any of the following:

— an argument had a trailing slash (/) but was not a directory
— unable to find a file
— unable to open an input file for reading
— unable to create or open an output file
— a read error occurred on an input file
— a write error occurred on an output file
— the input and output files were the same file
— encountered a fatal error when using -r or -R
Possible fatal -r or -R errors include:
— inability to access a file
— inability to change permissions on a target file
— inability to read a directory
— inability to create a directory
— a target that is not a directory
— source and destination directories are the same
2

Failure due to any of the following:

— an invalid command line option
— too few arguments on the command line
— a target that should be a directory but is not
— no space left on target device
— out of memory to hold the data to be copied
— inability to create a directory to hold a target file
cannot allocate target string

cp has no space to hold the name of the target file. Try to free up some memory to give cp more space.

"name" is a directory (not copied)

You did not specify -r or -R, but one of the names you asked to copy was the name of a directory.

"target name"?

You are attempting to copy a file with the -i option, but there is already a file with the target name. If you have specified -f, you can write over the existing file by typing y and pressing ENTER; if you do not want to write over the existing file, type n and press ENTER. If you did not specify -f and the file is read only, you are not given the opportunity to overwrite it.

source "name" and target "name" are identical

The source and the target are actually the same file (for example because of links, on UNIX and POSIX-compliant systems). In this case, cp does nothing.

unreadable directory "name"

cp cannot read the specified directory, for example, because you do not have appropriate permissions.


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0.

The -c, -f, -m, and -v options are extensions to the POSIX standard.


SEE ALSO

Commands:
cat, ln, mv, rm


Updated MKS Toolkit [3khat16.ico]HP3000 [3khat16.ico]3kMail [archive16.gif]