Copying a file
Use the cp command to copy a file. The syntax is
cp -ip filename1 filename2
where filename1 is the file you want copied and filename2 is
where you want it copied to.
For example,
cp memo memo.bak
would copy the file "memo" to a file named "memo.bak".
The DOS equivalent of this command is copy.
As with all commands, you can indicate directory paths using the following
abbreviations:
. current directory
.. parent (previous) directory
~ home directory
For example, the command
cp ~/personal/letter ~/old
would copy the file "letter" from the "Personal" directory and create
a copy in the "old" directory.
Warning: If filename2 already exists, cp replaces
the contents of filename2 with the contents of filename1.
If filename2 does not exist, cp creates it
and copies the contents of filename1 into it.
The -i option sets a confirmation prompt whenever cp would
overwrite an existing file.
The -p option preserves the modification times and security
permissions of the original file so that the newly created file (filename2)
has the same characteristics as the original file (filename1).
If you do not include -p, the cp command sets
the modification time of filename2 to be the time you issued the
command, even if the original file was last changed weeks or months ago.
The -p option does not copy AFS access privileges (see Security for information about AFS privileges).
Last modified
July 20, 2004
by cawalker
|