LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-16-2009, 01:26 AM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Rep: Reputation: 51
mv lacks --recursive option. cp does not.


How can do to move a given subtree into some other "node" of / (the root of the tree)? If I use cp or rm I can always use option --recursive. But that's not the case with mv.

Am I forced to write a script containing the two commands? Thanks for reading.
 
Old 05-16-2009, 01:34 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
If you move a directory, logically the contents must go with it, so there is no need for a recursive option
 
Old 05-16-2009, 02:31 AM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Original Poster
Rep: Reputation: 51
Thanks. I now see cp and mv have exactly the same syntax, cp|mv SOURCE DIRECTORY which is pretty much logical. But then, why the --recursive option in cp? I see I never quite understood it. (I'm not sure this is a question because, if I confess I don't understand it, I should at least study it a bit before posting.
 
Old 05-16-2009, 02:34 AM   #4
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
I may want to copy the files in a directory, or the files in a directory, any sub-directories and the files in them, etc.
 
Old 05-16-2009, 03:51 AM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Original Poster
Rep: Reputation: 51
I have the subtree

d1
<TAB> d2/f1
<TAB> f2

and want to copy it to directory .../e1/, what's the ifference between 'cp ./d1 .../e1/' and
'cp --recursive ./d1 .../e1/'?
 
Old 05-16-2009, 05:41 PM   #6
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Set yourself up a test directory and try this stuff.

I take it you mean d2 is a directory within d1?

cp d1 e1 will only copy f2, with a message that directory d2 wasn't copied.

cp -r d1 e1 will copy f2, and d2 containing f1
 
Old 05-17-2009, 04:55 AM   #7
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Original Poster
Rep: Reputation: 51
Yes, it is.

Reply most instructive. And it tells me setting oneself examples in order to study a man page is an advisable thing
to do. Thanks a lot and, by the way, how could I make the system notify me when I get a new linuxquestion
post, assuming I'm either in a text console or in the GUI?
(That is, assuming nothing, for either i'm in the one or i'm in the other, i think.)

Enrique.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ls with recursive option and file name doesn't work FromFPan2Fire Linux - Newbie 7 01-05-2010 11:21 AM
Xubuntu Partitioner lacks an option Nazurin Linux - Newbie 1 12-24-2008 02:43 PM
KDE shutdown menu lacks 'reboot' option leupi Linux - Software 4 03-02-2006 03:12 PM
Mplayer lacks an icon... ?!? Bakambauer Linux - Software 4 04-10-2004 05:58 PM
Kwrite has programming features that even DW lacks? Pcghost Programming 2 11-06-2003 11:52 PM


All times are GMT -5. The time now is 02:30 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration