next up previous contents index
Next: Pruning Back with rm Up: Moving Information Previous: Moving Information

cp Like a Monk

;

cp is a very useful utility under Unix, and extremely powerful. It enables one person to copy more information in a second than a fourteenth century monk could do in a year.

Be careful with cp if you don't have a lot of disk space. No one wants to see Error saving--disk full. cp can also overwrite existing files--I'll talk more about that danger later.

The first parameter to cp is the file to copy--the last is where to copy it. You can copy to either a different filename, or a different directory. Let's try some examples:

screen5168

The first cp command I ran took the file /etc/rc;, which contains commands that the Unix system runs on boot-up, and copied it to my home directory. cp doesn't delete the source file, so I didn't do anything that could harm the system. So two copies of /etc/rc exist on my system now, both named rc, but one is in the directory /etc and one is in /home/larry.

Then I created a third copy of /etc/rc; when I typed cp rc frog--the three copies are now: /etc/rc, /home/larry/rc and /home/larry/frog. The contents of these three files are the same, even if the names aren't.

The above example illustrates two uses of the command cp. Are there any others? Let's take a look:

One last thing in this section--how can you show the parameters that cp takes? After all, the parameters can mean two different things. When that happens, we'll have two different lines:

cp source destination-name
cp file1 file2 ...fileN destination-directory

;


next up previous contents index
Next: Pruning Back with rm Up: Moving Information Previous: Moving Information

Converted on:
Mon Apr 1 08:59:56 EST 1996