0% found this document useful (0 votes)
30 views1 page

CP (Unix) : Operating Modes

cp is a UNIX command used for copying files and directories. It has three main modes of operation: (1) copying a single source file to a destination file, (2) copying one or more source files to a destination directory, and (3) recursively copying the contents of an entire source directory, including subdirectories, to a destination directory. The command accepts various option flags to specify additional behaviors and can copy either individually or recursively depending on the arguments provided.

Uploaded by

Meena G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views1 page

CP (Unix) : Operating Modes

cp is a UNIX command used for copying files and directories. It has three main modes of operation: (1) copying a single source file to a destination file, (2) copying one or more source files to a destination directory, and (3) recursively copying the contents of an entire source directory, including subdirectories, to a destination directory. The command accepts various option flags to specify additional behaviors and can copy either individually or recursively depending on the arguments provided.

Uploaded by

Meena G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

cp (Unix)

From Wikipedia, the free encyclopedia



This article needs additional citations for verification. Please
help improve this article by adding citations to reliable sources. Unsourced
material may be challenged and removed. (December 2011)

Wikibooks has a book on
the topic of: Guide to
Unix/Commands/File
System Utilities#cp
cp is a UNIX command for copying files and directories. The command has three principal
modes of operation, expressed by the types of arguments presented to the program for copying
a file to another file, one or more files to a directory, or for copying entire directories to another
directory.
The utility further accepts various command line option flags to detail the operations performed.
The two major specifications are POSIX cp and GNU cp. GNU cp has many additional options
over the POSIX version.
[1]

Contents
[hide]
1 Operating modes
2 Usage
3 Option flags
4 Examples
5 Related Unix commands
6 See also
7 References
Operating modes[edit]
Cp has three principal modes of operation. These modes are inferred from the type and count of
arguments presented to the program upon invocation.
When the program has two arguments of path names to files, the program copies the
contents of the first file to the second file, creating the second file if necessary.
When the program has one or more arguments of path names of files and following those an
argument of a path to a directory, then the program copies each source file to the destination
directory, creating any files not already existing.
When the program's arguments are the path names to two directories, cp copies all files in
the source directory to the destination directory, creating any files or directories needed. This
mode of operation requires an additional option flag, typically r, to indicate the recursive
copying of directories. If the destination directory already exists, the source is copied into the
destination, while a new directory is created if the destination does not exist.

You might also like