LinuxQuestions.org
Help answer threads with 0 replies.
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-05-2010, 09:08 AM   #1
pantera975
LQ Newbie
 
Registered: Mar 2010
Posts: 3

Rep: Reputation: 1
Recursive copying...


Does anyone know of a way I can recursively copy 1 file into multiple directories? I have an index.html file that needs to be copied to every folder inside my /var/www/html directory. These directories can change in the future when people add new folders and I just want a cron job that runs daily and checks for new folders in /var/www/html and if it finds one, copy index.html to it.
 
Old 05-05-2010, 09:11 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
I would use "find" with the "-exec" option
 
Old 05-05-2010, 09:54 AM   #3
pantera975
LQ Newbie
 
Registered: Mar 2010
Posts: 3

Original Poster
Rep: Reputation: 1
Thanks alot! I never knew about "-exec". I got it pretty quick using..

find . -type d -exec cp index.php {} \;
 
Old 05-05-2010, 11:41 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
I have just given you your first "thank you"---simply for taking the hint and running with it. You have no idea how rare this is..
 
  


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
mv not recursive? BeacoN Linux - General 7 10-10-2012 06:46 AM
recursive ls harsshal Linux - Newbie 10 05-16-2008 04:41 AM
Recursive compilation Genjix Programming 1 12-07-2004 07:23 AM
rm -r what is recursive wogga Linux - Software 3 05-28-2004 02:29 PM
Recursive wildcard copying? meeshka Linux - Newbie 7 07-11-2003 01:44 AM


All times are GMT -5. The time now is 09:23 PM.

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