Previous Section  < Day Day Up >  Next Section

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.15.

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 has its original name.

  3. Recursively copies the entire desktop directory into /usr/bin/tester.

    Previous Section  < Day Day Up >  Next Section