next up previous contents
Next: Between UNIX systems (rcp) Up: Copying files Previous: Copying files   Contents

On the same system (cp)

To copy one file to another use the command cp. Unlike the command mv, cp will keep the first file; but like mv, cp will wipe out the prior contents of the target file. Note that the contents of the target file are erased before the first file is copied (like mv: you may wish to ``alias'' cp to ``cp -i''). Therefore, if you copy a file onto itself, you may end up with an empty file. Some systems, such as the Suns, won't allow you to do this anyway.

You can also use cp to move any number of files into a directory. The format for cp is:

cp originalfile newfile
cp file1 file2 file3 directory

The first kind of statement will copy the contents of originalfile into (i.e. over) newfile. The latter case will copy the three files into the specified directory.



h.stilmack@jach.hawaii.edu