LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to copy 1 file in 100's of subdirectories (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-copy-1-file-in-100s-of-subdirectories-425153/)

oadvantage 03-15-2006 04:29 PM

How to copy 1 file in 100's of subdirectories
 
HI.

I have a file called, resources.html and I need this file to goto in a every subdirectory in do_roots directory.

What is an easy way to do this?


Thank you for your help!!!!

haertig 03-15-2006 04:43 PM

Quote:

I have a file called, resources.html and I need this file to goto in a every subdirectory in do_roots directory.
You probably want to create symbolic links to the file rather than copy it, or possibly create hard links to it. To actually COPY, replace XXX below with "cp". To create SYMBOLIC LINKS, replace XXX with "ln -s". To HARD LINK, replace XXX with "ln".
Code:

# cd do_roots
# echo "the file contents" > resources.html
# for dir in `find . -type d -print`
  do
    XXX resources.html $dir/
  done
#


gilead 03-15-2006 04:44 PM

There's a similar question to this in http://www.linuxquestions.org/questi...d.php?t=423445. If your directory structure starts in /var/www/html and the file to copy is in /tmp/resources.html:
Code:

find /var/www/html -type d -exec cp /tmp/resources.html {} \;
That'll be slow but it worked for me for a small number of files.

berbae 03-15-2006 04:48 PM

cd do_roots
find . -type d -exec cp /directory/where/is/resources.html {} \;


All times are GMT -5. The time now is 04:11 AM.