recursive copy into a directory and all its subdirectories...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers recursive copy into a directory and all its subdirectories...
# 1  
Old 03-09-2012
recursive copy into a directory and all its subdirectories...

I want to copy a file from the top directory into all the sub-folders and all of the sub-folders of those sub-folder etc. Does anyone have any idea how to do this?

Thanks in advance of any help you can give.
# 2  
Old 03-09-2012
Code:
find /dir/to/copy/inside -type d -exec cp -n /path/to/originalfile '{}' ';'

The -n should prevent cp from overwriting any existing files of the same name.
# 3  
Old 03-09-2012
Try using find as follows - from the top directory where the file is;

Code:
find . -type d -exec cp filename {} \;

That should do it!

Regards

Dave
# 4  
Old 03-09-2012
Thanks very much guys! That works perfectly.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Recursive (Into subdirectories) ffmpeg generate jpg from video

My question is how to modify my existing script to generate from videos (mp4,avi,mkv etc...) jpegs via ffmpeg and keep folder name of generated jpg file? So if i have video in /home/videos/MyParty2009/SOmeDirR/VideoSomeTitle.mp4 and it will generate jpg with name of MyParty2009.jpg so the... (2 Replies)
Discussion started by: ZerO13
2 Replies

2. HP-UX

Recursive copy of Folders with files

Dear All, I will appreciate any help received. Our system is running on hpux v1 My problem is as follows: We have many customer folders with name fd000100, fd000101 and so on e.g. (Testrun)(testsqa):/>ll /TESTrun/fd000100 total 48 drwxrwx--- 2 fq000100 test 96 Jun 27 2004... (17 Replies)
Discussion started by: mhbd
17 Replies

3. Shell Programming and Scripting

recursive search and copy

Hello again. Well, I need help again sooner as I thought. Now I want to search for files with a known name within all subdirs, and copy the to differently named files in the same directory. For example if I had only one file to copy, I would just usecp fileName newFileNamebut to do this... (1 Reply)
Discussion started by: cabaciucia
1 Replies

4. Shell Programming and Scripting

Copying subdirectories of a directory to some other directory and renaming them

Hi, I am a newbie in shell scripting. I have to copy a particular sub-directory (data) from a large no. of directories (all in the same folder) and paste them to another directory ( /home/hubble/data ) and then rename all the subdirectories (data) as the name of its parent directory. please... (8 Replies)
Discussion started by: sholay
8 Replies

5. UNIX for Dummies Questions & Answers

help with recursive copy command

Hi Guys, I am experiencing a problem right now while copying a directory as well as its subdirectories to my target directory. I know this is a very simple UNIX command using cp -R source directory target directory. but unfortunatley while doing this an error comes up on the command line saying... (2 Replies)
Discussion started by: Knowledge_Xfer
2 Replies

6. AIX

recursive archive directories and subdirectories

Hi everyone, Maybe this is simple question for many of you, but I get confused.:confused: How to archive a parent directory which contains some subdirectories and some files? I have searched this forum, there are some commands like tar,etc, I tried but can not be implemented in my system.... (6 Replies)
Discussion started by: wilsonSurya
6 Replies

7. UNIX for Dummies Questions & Answers

Recursive copy to a RANDOM name

Dear Group, after trying numerous suggestions and racking my brain I cannot manage something which seems so simple. Essentiallly, I would like to perform a recursive copy to a destination but give it a random name. I assumed (incorrectly) that the following would work: cp -r... (10 Replies)
Discussion started by: xerexes
10 Replies

8. Programming

recursive copy of the directory

I want to copy a directory recursively ( it again has directories) and the directory is on windows and is nfsmounted in vxWorks, i am using unix to develop the code for this, can any one suggest me how to copy the directories recursively. (7 Replies)
Discussion started by: deepthi.s
7 Replies

9. Shell Programming and Scripting

copy certain files from subdirectories

Hi all, I'd very grateful for some help with the following. I have a variable number of subdirectories each of which contain a uniquely names results file of the form Results*.dat. I would like to search through all subdirectories and copy out these results file to another directory so that... (3 Replies)
Discussion started by: iomaire
3 Replies

10. UNIX for Advanced & Expert Users

recursive copy of hidden files

I need to know how to copy hidden files recursively? cp -r sourceDir/* targetDir/. ignores the hidden files. Thank you!! (2 Replies)
Discussion started by: usfrog
2 Replies
Login or Register to Ask a Question