[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help with command - cp



Your requirement (to skip hidden files and directories) is what is
usually required.

But, as a generic rule, you can use the echo command to help with
analysing how the command line shell might expand a wild card.

echo cp /path/to/src/* /path/to/dest > some_tmp_file

If I do this on my home directory, I could a huge list as I have too
many files.  Which is why I redirected the output to a file.  And
looking in the file, I find that there are no hidden directories or
files copied.

If we look at your command line, you have two switches -R and -p.
The -R turns on recursive copying, not only is every file
in .../sourcedir/A copied, every subdirectory of .../sourcedir/A, and
subdirectories of those, to the end of the file tree is copied.  The -p
switch asks for the preservation of metadata: ownership, groupship, and
times.

If you are the owner of the files  under sourcedir/A and you are also
the owner of destinationdir/B, I would expect the ownership and
groupship to already be proper, and so it is only the file time
information which is being preserved.  Preserve is important if root is
doing the copying.

Gord


Reply to: