Cp (Unix)
Cp (Unix)
Main page
2147108

Cp (Unix)

logo
Community Hub0 subscribers
What are your thoughts?
Be the first to start a discussion here.
Be the first to start a discussion here.
Cp (Unix)

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.

The command was part of Version 1 Unix, and is specified by POSIX. The implementation from GNU has many additional options beyond the POSIX specification. The command is bundled in GNU Core Utilities and is available in the EFI shell.

The command has three principal modes of operation as inferred from command-line arguments.

For a path to an existing file followed by a path that does not refer to an existing directory, the file at the first path is copied to the second path.

For one or more paths to existing files followed by a path to an existing directory, the files are copied to the directory.

With the recurse command-line option, typically -r, a path to an existing directory and a second path, the files of the directory are copied to the second path. If the second path refers to nothing, the source directory is copied to that path. If the second path refers to an existing directory, the source directory is copied into the destination directory as a subdirectory.

This copies file prog.c to file prog.bak. If prog.bak does not already exist, this creates it. If it does exist, its content will be replaced.

See all
User Avatar
No comments yet.