Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-15-2006, 05:29 PM   #1
LQ Newbie
Registered: Mar 2006
Posts: 12

Rep: Reputation: 0
How to copy 1 file in 100's of subdirectories


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
Senior Member
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,277

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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".
# cd do_roots
# echo "the file contents" > resources.html
# for dir in `find . -type d -print`
     XXX resources.html $dir/
Old 03-15-2006, 05:44 PM   #3
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,138

Rep: Reputation: 167Reputation: 167
There's a similar question to this in If your directory structure starts in /var/www/html and the file to copy is in /tmp/resources.html:
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
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 {} \;


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:41 AM.

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