cp Top Level
cp
Quick and Concise Document
Beginners
Command Description
------- -----------
cp file1 file2 Place a copy of file1 in file2.
cp /path/file1 ~ Copy a file from another directory into your
home directory.
cp file1 /dir Place a copy of file1 in the current directory
into a specified directory.
Use the cp command to create a copy of a file, using a new filename for
the copy.
cp file1 target
For example:
world% cp my.article published.docs
file1 is copied (linked, moved) to target. Under no circumstance can
file1 and target be the same (take care when using metacharacters).
If target is a directory, then one or more files are copied to that
directory. If target is an existing file, its contents are destroyed.
When cp is invoked, if target is not an existing file, a new file is
created which has the same mode as file1 except that the sticky bit is
not set; the owner and group of target are those of the user. If
target is a file, copying a file into target does not change its mode,
owner or group. The last modification time of target (and last access
time, if target did not exist) and the last access time of file1 are
set to the time the copy was made. If target is a link to a file, all
links remain and the file is changed.
If you were in the directory /ftp/obi/Martin.Luther.King, you could
make a copy of a famous Martin Luther King speech to be placed into
your home directory with the command:
world% cp free.at.last ~
The tilde "~" here refers to your home directory and the filename will
remain unchanged. Once you issue this command, a copy of the document
free.at.last is added your home directory.
If you wanted to place a copy of a file in the current directory into
another directory, you must give the full pathname to that directory:
world% cp my.article /tmp
The -p option will cause the modification time, permissions, owner, and
group of the target to be set to those of file1 after the file is copied.
If the -i option is specified the user is prompted with the message:
overwrite target?
If the user answers with a line starting with `y', the copy continues.
Any other reply prevents the command from completing.
If the -r option is specified with cp and any of the source files are
directories, cp copies each subtree rooted at that name; in this case
target must be a directory.
HOME Top of Help Desk Eye On The World The World Kiosk
For further assistance, please send an email
request to support@world.std.com
Copyright 1995 Software Tool & Die, Inc. All Rights Reserved.
Software Tool & Die, Inc., 1330 Beacon St. Suite 215 Brookline, MA 02146