home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: compress Chapter 2
UNIX Commands
Next: Reference: cpio
 

cp



cp

 [

options

] 

file1

 

file2




cp

 [

options

] 

files

 

directory

Copy file1 to file2 , or copy one or more files to the same names under directory . If the destination is an existing file, the file is overwritten; if the destination is an existing directory, the file is copied into the directory (the directory is not overwritten). If one of the inputs is a directory, use the -r option.

Options

-i

Prompt for confirmation ( y for yes) before overwriting an existing file.

-p

Preserve the modification time and permission modes for the copied file. (Normally cp supplies the permissions of the invoking user.)

-r

Recursively copy a directory, its files, and its subdirectories to a destination directory , duplicating the tree structure. (This option is used with the second command-line format when at least one of the source file arguments is a directory.)

Example

Copy two files to their parent directory (keep the same names):



cp outline memo ..


Previous: Reference: compress UNIX in a Nutshell: System V Edition Next: Reference: cpio
Reference: compress Book Index Reference: cpio

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System