Modular Computers the manual GitHub

cp

cp: copy files and directories.

Synopsis

cp [-r] source dest
cp [-r] source… directory

Description

cp copies source to dest. If the last argument is an existing directory, each source is copied into it under its own name. With more than one source, the last argument must be a directory.

An existing file is overwritten. Without -r, a symbolic link given as a source is followed, and its target’s contents are copied; a directory is refused.

Options

-r, -R
Copy directories and everything in them. Directories are created as needed (an existing one is copied into), and symbolic links inside are copied as links, never followed.

Options may appear anywhere among the arguments.

Exit status

0 on success; 1 if any copy failed or the arguments were wrong.

Examples

cp notes.txt notes.bak
cp -r /home /mnt/sata/1/backup
cp a.lua b.lua /tmp

Notes

Copying stops at the first error inside a directory tree. There is no -i, -n, -p or -v, and copies keep no attributes of the original.

See also

mv(1), rm(1), ln(1), mkdir(1)