Skip to content
EntityQ305946· pop 30· linked from 244 articles

UNIX command for copying files and directories

In the Vinony graph

Within Vinony's link graph, cp is referenced by 244 other articles, and connects out to list of UNIX commands, GNU Core Utilities and ln.

It sits within the topics File copy utilities, IBM i Qshell commands and Inferno (operating system) commands.

Its subject is documented across 30 Wikipedia language editions.

Key facts

Original author
AT&T Bell Laboratories
Developers
Various open-source and commercial developers
Initial release
November 3, 1971 ; 54 years ago ( 1971-11-03 )
Written in
Plan 9: C
Operating system
Unix , Unix-like , Plan 9 , Inferno , KolibriOS
Platform
Cross-platform
Type
Command
License
coreutils : GPLv3 , Plan 9: MIT License

via Wikipedia infobox

Described at

If target does not exist and two operands are specified, the name of the corresponding destination path for source file shall be target ; the name of the corresponding destination path for all other files in the file hierarchy shall be the concatenation of target , a character, and the pathname of the file relative to source file . If the -R option was not specified, cp shall take actions based on the type and contents of the file referenced by the symbolic link, and not by the symbolic link itself, unless the -P option was specified. If the -P option was specified, cp shall copy any symbolic link specified as a source file operand and any symbolic links encountered during traversal of a file hierarchy, and shall not follow any symbolic links. 4. Otherwise, the -R option was specified, and the following steps shall be taken: 1. The dest file shall be created with the same file type as source file . If the implementation provides additional or alternate access control mechanisms (see XBD File Access Permissions ), their effect on copies of files is implementation-defined. Take actions based on the type and contents of the file referenced by any symbolic link specified as a source file operand. Write a prompt to standard error before copying to any existing non-directory destination file. If the response from the standard input is affirmative, the copy shall be attempted; otherwise, it shall not. Take actions based on the type and contents of the file referenced by any symbolic link specified as a source file operand or any symbolic links encountered during traversal of a file hierarchy. 1. The time of last data modification and time of last access. If this duplication fails for any reason, cp shall write a diagnostic message to standard error. 3. The file permission bits and the S ISUID and S ISGID bits. Other, implementation-defined, bits may be duplicated as well. If this duplication fails for any reason, cp shall write a diagnostic message to standard error. The order in which the preceding characteristics are duplicated is unspecified. The dest file shall not be deleted if these characteristics cannot be preserved. The standard input shall be used to read an input line in response to each prompt specified in the STDERR section. Otherwise, the standard input shall not be used. The input files specified as operands may be of any file type. Provide a default value for the internationalization variables that are unset or null. (See XBD Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) If set to a non-empty string value, override the values of all the other internationalization variables. Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements used in the extended regular expression defined for the yesexpr locale keyword in the LC MESSAGES category. Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files) and the behavior of character classes used in the extended regular expression defined for the yesexpr locale keyword in the LC MESSAGES category. Determine the locale used to process affirmative responses, and the locale used to affect the format and contents of diagnostic messages and prompts written to standard error. [XSI) ] ![[Option Start]]( Determine the location of message catalogs for the processing of LC MESSAGES. ![[Option End]]( A prompt shall be written to standard error under the conditions specified in the DESCRIPTION section. The prompt shall contain the destination pathname, but its format is otherwise unspecified. Otherwise, the standard error shall be used only for diagnostic messages. The set-user-ID and set-group-ID bits are explicitly cleared when files are created. This is to prevent users from creating programs that are se

Excerpt from a page describing this subject · 27,838 chars · not written by Vinony

Wikidata facts

Has use
copying
Show 2 more facts
has command line option
X
Sources (2)

via Wikidata · CC0

~4 min read

Encyclopedic overview

cp is a shell command for copying files and directories.

If the user has write access to a target file, the command copies the content by opening it in update mode. This preserves the file's inode instead of creating a new file with default permissions.

Excerpted from Wikipedia’s “cp” article, available under the CC BY-SA 4.0 licence.

Categories