LinuxQuestions.org
Visit Jeremy's Blog.
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-15-2006, 05:29 PM   #1
oadvantage
LQ Newbie
 
Registered: Mar 2006
Posts: 12

Rep: Reputation: 0
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!!!!
 
Old 03-15-2006, 05:43 PM   #2
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian
Posts: 2,210

Rep: Reputation: 341Reputation: 341Reputation: 341Reputation: 341
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
#
 
Old 03-15-2006, 05:44 PM   #3
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,125

Rep: Reputation: 165Reputation: 165
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.
 
Old 03-15-2006, 05:48 PM   #4
berbae
Member
 
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

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


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
copy a file to all subdirectories in a folder raj000 Linux - General 6 03-24-2006 04:55 AM
monitoring file added to a directory / subdirectories abhi_abhijith Programming 4 02-13-2006 08:25 AM
copy 3 files to a directory and all subdirectories? snip128 Linux - Newbie 9 08-12-2005 10:18 PM
Is arrangement of file systems will differ if we copy a file from FAT 32 to ext 3 ? anindyanuri Linux - Software 2 02-20-2005 12:39 PM
copy directories and subdirectories Red Squirrel Linux - Newbie 2 03-06-2004 10:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:33 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