LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-11-2005, 12:58 PM   #1
juanb
Member
 
Registered: May 2002
Posts: 401

Rep: Reputation: 30
cp command


HI,

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


thanks,

Juan
 
Old 09-11-2005, 01:00 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
cp -R

man cp
 
Old 09-11-2005, 01:55 PM   #3
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
* slackie1000 is just being boring... *
hi there,
if you want the same effect with one keystroke less..
Code:
cp -r

regards,
slackie1000
 
Old 09-11-2005, 02:26 PM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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.)
 
Old 09-11-2005, 03:57 PM   #5
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
hi there,
Matir, did you get this message direct from man cp??
from mine...
Code:
 -R, -r, --recursive
              copy directories recursively
interesting...
regards,
slackie1000
 
Old 09-11-2005, 04:02 PM   #6
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Very odd. Yes, it was copied and pasted. What cp version do you have?
Code:
$ cp --version
cp (coreutils) 5.2.1
...
 
Old 09-11-2005, 04:04 PM   #7
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
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
 
Old 09-11-2005, 04:07 PM   #8
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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'
 
Old 09-11-2005, 04:10 PM   #9
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
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
 
Old 09-11-2005, 04:11 PM   #10
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Interesting. Never an occasion where you DON'T want to preserve permissions?
 
Old 09-11-2005, 04:16 PM   #11
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
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
 
Old 09-11-2005, 04:20 PM   #12
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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.
 
Old 09-11-2005, 04:20 PM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
Old 09-11-2005, 04:27 PM   #14
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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.
 
Old 09-11-2005, 05:02 PM   #15
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM
Why after start of a command the invitation for input next command has not appeared. ukrainet Linux - General 3 06-24-2005 08:16 AM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM
Where is Command line utility for Cups and command tutorial mossy Linux - Software 8 01-16-2004 12:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration