copy(C)


copy -- copy groups of files

Syntax

copy [ option ] ... source ... dest

Description

The copy command copies the contents of directories to another directory. It is possible to copy whole file systems since directories are made when needed.

If files, directories, or special files do not exist at the destination, then they are created with the same modes and flags as the source.

Note that there may be more than one source directory. If so, the effect is the same as if the copy command had been issued for each source directory with the same destination directory for each copy.

Options do not have to be given as separate arguments, and may appear in any order, even after the other arguments. The options are:


-a
Asks the user before attempting a copy. If the response does not begin with a ``y'', then a copy is not done. When used together with the -v option, it overrides the verbose option so that messages regarding the copy action are not displayed.

-ad
Asks the user whether a -r flag applies when a directory is discovered. If the answer does not begin with a ``y'', then the directory is ignored.

-l
Uses hard links instead whenever they can be used. Otherwise a copy is made. If the destination file already exists (of the same type as, but not identical to the source file), it is unlinked before copying. Note that hard links are never made for directories.

-m
If set, then every file copied has its modification time and access time set to that of the source. If not set, then the modification time is set to the time of the copy.

-n
Requires the destination file to be new. If not, then the copy command does not change the destination file. The -n flag is meaningless for directories.

-o
If set, then every file copied has its owner and group set to those of the source. If not set, then an existing file's owner is unchanged, and a new file's owner is the user who invoked the program.

-r
If set, then every directory is recursively examined as it is encountered. If not set then any directories that are found are ignored.

-s
Uses symbolic links whenever they can be used. Otherwise a copy is made. If the destination file already exists (of the same type as, but not identical to the source file), it is unlinked before copying. Note that symbolic links are never made for directories.

-v
Messages are printed that reveal what the program is doing. If used with the -a option, the -a option is given priority so that it overrides the verbose option, and the copy action message is not displayed.
Arguments to copy are:

source
This may be a file, directory or special file. It must exist.

dest
If the destination is an existing directory, source files are copied into it. If the destination is an existing file, it must be of the same type (regular or special file) as the source file. If the destination does not exist, it is created as a directory if the source is a directory, or if there are multiple source files. Otherwise destination is created as a file of the same type as the source file.

Examples

This command line verbosely copies all files in the current directory to /tmp/food:

copy -v . /tmp/food

The next command line copies all files, except for those that begin with a dot(.), and copies the immediate contents of any child directories:

copy * /tmp/logic

This command is the same as the previous one, except that it recursively examines all subdirectories, and it sets group and ownership permissions on the destination files to be the same as the source files:

copy -ro * /tmp/logic

Limitations

Special device files can be copied or linked. No data associated with the device is copied. A device node is created identical to the source device node, or a link is made to the source device node (if the -l or -s options are specified). Only the superuser can create device nodes.

The -m and -o options have no effect on created hard or symbolic links when the options -l or -s are also specified. This is because a hard link references the same inode as the source file; the ownership and time stamp stored in an inode are not changed when a hard link to it is created. The ownership and time stamp of a symbolic link cannot be changed; attempting to do this would cause the link to be followed and the change would be attempted on the linked file.

Standards conformance

copy is not part of any currently supported standard; it is an extension of AT&T System V provided by the Santa Cruz Operation.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005