Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the man page for cp, what is the difference between copying to DEST and DIRECTORY?

cp copies a SOURCE to a DEST and SOURCES to a DIRECTORY.


   cp [OPTION]... [-T] SOURCE DEST
share|improve this question

With DEST it is assuming you are naming the file name and path (and therefore directory) of the destination file. With DIRECTORY you are just listing which directory the destination file will be in, while preserving the SOURCE name.

share|improve this answer

If SOURCE is just one file, the difference depends on what the command finds: If there is a directory DEST, SOURCE is copied into it, preserving the name. If it does not exist or is a file, DEST is interpreted as new name to use, eventually overriding DEST if it is a file.

If you have multiple SOURCES, DEST can only be a directory, since copying multiple files into one dest file would only preserve the last copied file and be rather useless for almost all cases.

A copy command:

cp s1 s2 s3 d1 d2 d3 

would look as if it would make some sense, since an even number of names could match s1 -> d1, s2 -> d2 ... , but think of shell expansion:

cp * 

could result in different interpretation, depending on the number of files matched by *. So if you use multiple files, the last is always assumed to be a directory. If it doesn't exist, you get an error message.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.