cp
From NetBSD Wiki
cp -- copy files
The cp(1) utility is used for copying either a single file to a new file or multiple files into a directory.
Contents |
Single file
If there are 2 file name operands, and the last is not a directory, the file referred by the first operand is copied to the second.
% ls a % cp a b % ls a b
Recursively copying a directory
If you want to copy directories, use the following:
% cp -R /path/to/source /path/to/destination
For more information about the differences between -R and -r please read the manpage of cp(1).
Multiple files to directory
If the last operand is a directory, all the other operands represents files which are copied to that directory.
% ls -l total 2 -rw-r--r-- 1 testuser users 0 Jul 13 23:23 a -rw-r--r-- 1 testuser users 0 Jul 13 23:23 b drwxr-xr-x 2 testuser users 512 Jul 13 23:23 d % ls -l d/ % cp a b d % ls -l d/ total 0 -rw-r--r-- 1 testuser users 0 Jul 13 23:24 a -rw-r--r-- 1 testuser users 0 Jul 13 23:24 b
