I go with the following in bash
cp -r "/wordpress/3.0.1/" "/mySite/"
and the result is
/mySite/3.0.1/ but I don't want nor understand why the
3.0.1/ appears in the target destination.
What am I doing wrong?
cp -r /wordpress/3.0.1/* /mySite
This is a deviation from the POSIX specification, which states that
A pathname that contains at least one non-slash character and that ends with one or more trailing slashes shall be resolved as if a single dot character ( '.' ) were appended to the pathname.
But under Linux (i.e. with the
cp command from GNU coreutils,
cp -r foo/ bar/ acts like
cp -r foo bar/ rather than
cp -r foo/. bar/ when
foo is a directory¹. (GNU coreutils isn't the only culprit, I just observed the same behavior in OpenBSD which is usually good at standards compliance.)
You can run
cp -r "/wordpress/3.0.1/." "/mySite/" (i.e. end the source with
/.) to avoid the
3.0.1/ level. Another possibility is
rsync -r "/wordpress/3.0.1/" "/mySite/".
As an aside, I recommend getting into the habit of
cp -a rather than
cp -r if you don't use unices other than Linux and Cygwin. When you notice the difference,
-a (which preserves permissions and symbolic links) is usually the right one. On other unices, use
cp -Rp. With