LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 06-27-2007, 09:34 PM   #1
mlapl1
LQ Newbie
 
Registered: Jun 2007
Posts: 16

Rep: Reputation: 0
Copying a single file into each directory of a directory tree


Hello

I am trying to copy ONE file (php.ini) into EVERY directory of a directory hierarchy. I have tried simple things like cp -R /* but that did not work. I tried various forms of find but without success.

Can someone please help? I am getting desperate as there are many directories and subdirectories in the hierarchy and I may need to do this on several hierarchies.

Thank you so much

Andrew
 
Old 06-27-2007, 10:15 PM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Use the find command to locate the directories and execute the cp command:

find <basedir>/ -type d -exec cp php.ini '{}' \;

The -exec option executes the cp command for each directory found. The '{}' is a wild card which is replaced with the directory.
 
Old 06-27-2007, 10:18 PM   #3
mlapl1
LQ Newbie
 
Registered: Jun 2007
Posts: 16

Original Poster
Rep: Reputation: 0
Thank you so much - I will go and apply it immediately.

Andrew
 
  


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
Change file extentions in a directory tree threelions66 Linux - Newbie 2 11-27-2006 09:22 PM
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 10:55 PM
Copying a file into a directory Nizhni Linux - Newbie 3 01-24-2005 12:47 AM
duplicate directory tree for only certain file types curmudgeon42 Linux - Software 13 01-22-2005 02:38 PM
How to copy a directory tree without copying the files in it? system Linux - General 2 01-15-2002 09:36 PM


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

Main Menu
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