LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 03-06-2006, 05:41 PM   #1
oadvantage
LQ Newbie
 
Registered: Mar 2006
Posts: 12

Rep: Reputation: 0
Copying a Directory into Another Directory with Subdirectories


I am delving into Linux.

I want to copy the directory rss into a directory called doc_roots.

Inside of doc_roots are 100's of subdirectories where rss needs to be.

do I use cp? What is the command to install it into every subdirectory within doc_roots?

Thank you!
 
Old 03-06-2006, 05:51 PM   #2
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 47
So you want to copy the rss directory to all the sub directories of doc_roots?

like this:-

Code:
doc_roots
   |_sub1
   |  |_rss
   |_sub2
   |  |_rss
   ...
 
Old 03-06-2006, 06:18 PM   #3
oadvantage
LQ Newbie
 
Registered: Mar 2006
Posts: 12

Original Poster
Rep: Reputation: 0
yes, I need the new RSS to overwrite ALL of the old ones,but there is only one file I need in there.

For example.

The new rss has 3 files
a
b
c

The old has
a
b
c
d

When I over write them will D still remain in the directory since it is not present in the new version of will it be replaced?
 
Old 03-06-2006, 06:25 PM   #4
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 47
D will still remain, when you copy the directory, it will only replace the files in the old one, it doesn't delete the old directory first and then write the new one. If you want something to do that you'd need a script something like

Code:
#!/bin/sh
SRC=path/to/rss
DST=path/to/doc_roots

cd $DST
dirlist=( `ls -Qd */` )
numdirs=${#dirlist[@]}
for (( i=0; i < numdirs; i++)); do
    currdir=${dirlist[i]}
    cd currdir
    rm -rf rss
    cp -r $SRC ./
done
although that is just a quick example, and may not actually work properly or you.
 
Old 03-06-2006, 06:27 PM   #5
oadvantage
LQ Newbie
 
Registered: Mar 2006
Posts: 12

Original Poster
Rep: Reputation: 0
ok thank you!!!

I will try it
 
  


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
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 11:55 PM
why can't the /bin directory contain subdirectories? learnfast Linux - Newbie 2 03-09-2005 12:31 PM
Copying all files from subdirectories into one directory Hegemon Linux - General 3 01-17-2005 12:25 PM
howto mv a set of subdirectories to an other directory? Lleb_KCir Linux - General 1 06-14-2004 12:33 AM
read directory and subdirectories skora Programming 3 10-27-2003 11:22 PM


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