|CP(1)||General Commands Manual||CP(1)|
] source target
] source ... directory
cputility copies the contents of the source file to the target file. In the second synopsis form, the contents of each named source file are copied to the destination directory. The names of the files themselves are not changed. If
cpdetects an attempt to copy a file to itself, the copy will fail. The options are as follows:
-foption overrides any previous
-Roption is also specified, symbolic links on the command line are followed. Symbolic links encountered in the tree traversal are not followed.
y’, the file copy is attempted. The
-ioption overrides any previous
-Roption is also specified, all symbolic links are followed.
-Roption is also specified, no symbolic links are followed.
cpcopies the directory and the entire subtree connected at that point. Created directories have the same mode as the corresponding source directory, unmodified by the process's umask. This option also causes symbolic links to be copied, rather than followed, and special files to be created, rather than being copied as normal files. However,
cpcopies hard linked files as separate files. To preserve hard links, use a utility such as pax(1) or tar(1) instead.
-Rflag is specified. If the destination file does not exist, the mode of the source file is used as modified by the file mode creation mask (
umask, see csh(1)). If the source file has its set-user-ID bit on, that bit is removed unless both the source file and the destination file are owned by the same user. If the source file has its set-group-ID bit on, that bit is removed unless both the source file and the destination file are in the same group and the user is a member of that group. If both the set-user-ID and set-group-ID bits are set, all of the above conditions must be fulfilled or both bits are removed. Appropriate permissions are required for file creation or overwriting. When a file containing large blocks of zero-valued bytes is copied,
cpwill attempt to create a sparse file. Symbolic links are always followed unless the
-Rflag is set, in which case symbolic links are not followed, by default. The
-Lflags (in conjunction with the
-Rflag) cause symbolic links to be followed as described above. The
-Poptions are ignored unless the
-Roption is specified. In addition, these options override each other and the command's actions are determined by the last one specified.
cputility exits 0 on success, and >0 if an error occurs. foo named bar:
$ cp foo bar
$ cp *.txt /tmp
$ cp -R junk /tmp
cputility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification. The flag [
cputility had an
-roption. This implementation supports that option; however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links or FIFOs.
cpcommand appeared in Version 1 AT&T UNIX.
|June 28, 2017||OpenBSD-current|