cp—copies files

cp [ –i ] [ –p ] [ –r ] [ filename ... ] target

The cp command copies filename to another target, which is either a file or directory. The filename and target cannot have the same name. If the target is not a directory, only one file may be specified before it; if it is a directory, more than one file may be specified. If target does not exist, cp creates a file named target. If target exists and is not a directory, its contents are overwritten. If target is a directory, the file(s) are copied to that directory.

Example A.12.
1   cp file1 file2
2   cp chapter1 book
3   cp -r desktop /usr/bin/tester

EXPLANATION

  1. Copies the contents of file1 to file2.

  2. Copies the contents of chapter1 to the book directory. In the book directory, chapter1 ...

Get UNIX® Shells by Example, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.