LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cp command (https://www.linuxquestions.org/questions/linux-general-1/cp-command-362390/)

juanb 09-11-2005 12:58 PM

cp command
 
HI,

how on linux I copy all the content of a whole directory including sub directories?


thanks,

Juan

Matir 09-11-2005 01:00 PM

cp -R

man cp

slackie1000 09-11-2005 01:55 PM

* slackie1000 is just being boring... *
hi there,
if you want the same effect with one keystroke less..
Code:

cp -r
:cool:
regards,
slackie1000

Matir 09-11-2005 02:26 PM

Just as an FYI:
Quote:

From man cp:
-R Copy directories recursively, and do the right thing when
objects other than ordinary files or directories are encoun-
tered. (Thus, the copy of a FIFO or special file is a FIFO or
special file.)

-r Copy directories recursively, and do something unspecified with
objects other than ordinary files or directories. (Thus, it is
allowed, in fact encouraged, to have the -r option a synonym for
-R. However, silly behaviour, like that of the GNU 4.0 version
of cp is not forbidden.)

slackie1000 09-11-2005 03:57 PM

hi there,
Matir, did you get this message direct from man cp??
from mine...
Code:

-R, -r, --recursive
              copy directories recursively

interesting...
regards,
slackie1000

Matir 09-11-2005 04:02 PM

Very odd. Yes, it was copied and pasted. What cp version do you have?
Code:

$ cp --version
cp (coreutils) 5.2.1
...


slackie1000 09-11-2005 04:04 PM

hi there,
Code:

cp (coreutils) 5.2.1
Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.

Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

now, i can't reach my gentoo box but i think this man page was edited by gentoo staff. what i posted now come from my arch server. interesting thing. i always thought they - r // R - were exact the same. need to make some checks.
regards,
slackie1000

Matir 09-11-2005 04:07 PM

Mine definitely came from a gentoo box. Specifically, with sys-apps/coreutils-5.2.1-r6 installed. My guess is that GNU coreutils does implement -R and -r in the same manner, but the manpage describes possible other behavior for portability in scripting. I, for some reason, have always used 'cp -Rp'. Maybe I just think it looks nicer than 'cp -rp' :)

slackie1000 09-11-2005 04:10 PM

hi there,
ok. just to share with my side also...
i use cp like that.. first my alias...
Code:

alias cp="cp -vp"
and then the command..
Code:

cp -r
regards,
slackie1000

Matir 09-11-2005 04:11 PM

Interesting. Never an occasion where you DON'T want to preserve permissions?

slackie1000 09-11-2005 04:16 PM

hi there,
indeed.
i use this setup almost only as root and 90% of cp use is for backup purpose. that's why i think is interesting to keep original attributes: ownership + time
regards,
slackie1000

Matir 09-11-2005 04:20 PM

Quote:

Originally posted by slackie1000
hi there,
indeed.
i use this setup almost only as root and 90% of cp use is for backup purpose. that's why i think is interesting to keep original attributes: ownership + time
regards,
slackie1000

Ah, as root, it does make more sense. :)

Tinkster 09-11-2005 04:20 PM

There appears to be a difference between the
cp in coreutils and fileutils.

Coreutils' version shows what Slackie and I see,
fileutils' has what matir posted.


Cheers,
Tink

Matir 09-11-2005 04:27 PM

Oddly enough, my system does not have fileutils installed. However, the manpage information is for fileutils.
Quote:

NOTES
This page describes cp as found in the fileutils-4.1 package; other
versions may differ slightly.
I wonder if that would be considered a bug? OTOH, it may have been brought in by the man-pages package.

Tinkster 09-11-2005 05:02 PM

Quote:

Originally posted by Matir
I wonder if that would be considered a bug? OTOH, it may have been brought in by the man-pages package.
That would still constitute a bug on the packagers end
of the stick, wouldn't it?



Cheers,
Tink


All times are GMT -5. The time now is 02:01 PM.