copying to multiple directories using wildcard


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers copying to multiple directories using wildcard
# 1  
Old 05-22-2007
copying to multiple directories using wildcard

Can we copy a file to multiple directories using a single command line , i tried with * didnt work for me

cp /tmp/a.kool /tmp/folder/*/keys/


I am tryn to copy a.kool file to all keys folder in /tmp folder. is something i am missing ?
# 2  
Old 05-22-2007
This will copy a.kool and everything from /tmp/folder/* to /keys/.

You can use looping.

Make a list of folders where you want to copy in a text file.

for a in `cat list.txt`; do copy a.kool $a/; done;
# 3  
Old 05-22-2007
Quote:
Originally Posted by logic0
Can we copy a file to multiple directories using a single command line , i tried with * didnt work for me

cp /tmp/a.kool /tmp/folder/*/keys/


I am tryn to copy a.kool file to all keys folder in /tmp folder. is something i am missing ?
find /tmp/folder/ -type d -name keys -exec cp /tmp/a.kool {}\;

but be careful Smilie
# 4  
Old 05-22-2007
Try this Smilie

find . -path "/tmp/folder/*/keys/" -type d -exec cp /tmp/a.kool {} \;

may be similar to previous post Smilie
# 5  
Old 05-22-2007
sorry small correction

find /tmp/ -path "/tmp/folder/*/keys/" -type d -exec cp /tmp/a.kool {} \;
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error copying file using wildcard

Hi, cd /web/myf ls -ltr -rwxr-x--- 1 user1 Admin 17 Oct 7 15:53 mykey.db -rwxr-x--- 1 user1 Admin 21 Oct 7 15:53 test.shmore test.sh cd log01 pwd cp ../*.db .When i run the test.sh i get the below output / error. Output: /web/myf/log01 cp: cannot stat `../*.db': No such file... (5 Replies)
Discussion started by: mohtashims
5 Replies

2. UNIX for Dummies Questions & Answers

Copying Directories from one server to another

Hi, I have a requirement where I have to connect to another server and copy directories from one server to another Directories on the Source server look like below (YYYY-MM-DD- 1 to 23) drwxr-xr-x 2 test_user dmfmart 422 Sep 1 23:45 2014-09-01-18 drwxr-xr-x 2 test_user dmfmart ... (3 Replies)
Discussion started by: arunkesi
3 Replies

3. Shell Programming and Scripting

Copying data from files to directories

I have the following that I'd like to do: 1. I have split a file into separate files that I placed into the /tmp directory. These files are named F1 F2 F3 F4. 2. In addition, I have several directories which are alphabetized as dira dirb dirc dird. 3. I'd like to be able to copy F1 F2 F3 F4... (2 Replies)
Discussion started by: newbie2010
2 Replies

4. UNIX for Dummies Questions & Answers

Deleting multiple directories inside multiple directories

Hi, Very unfamiliar with unix/linux stuff. Our admin is on vacation so, need help very quickly. I have directories (eg 40001, 40002, etc) that each have one subdirectory (01). Each subdir 01 has multiple subdirs (001, 002, 003, etc). They are same in each dir. I need to keep the top and... (7 Replies)
Discussion started by: kkouraus1
7 Replies

5. Shell Programming and Scripting

Copying all directories while ignoring certain filetypes

I want to write a script that copys over a complete folder including the dirs to another location. However in the process I want to ignore several filetypse that SHOULD NOT get copied over. I know Global Ignore is capable of make the copy command ignore one file type, however I don't know how... (8 Replies)
Discussion started by: pasc
8 Replies

6. UNIX for Dummies Questions & Answers

Using find -d and copying to the found directories

Hi again All :) After posting my first thread just a few eeks ago and having such a great response (Thank You once again :) ), I thought I'd perhaps ask the experts again. In short I'm trying to achieve a "find" and "copy" where the find needs to find directories: find -d -name outbox and... (6 Replies)
Discussion started by: Dean Rotherham
6 Replies

7. Shell Programming and Scripting

check if multiple directories exist else create missing directories

Hi , I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory. how to write this in a simple script, I have made my code complex if ; then taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 Replies

8. UNIX for Dummies Questions & Answers

Concatenation of multiple files with wildcard

I have the following snippet to concatenate about a hundred csv-files: for file in *csv; do cat $file >> newfile; done This line works, but before I was experimenting with the following line, which is more intuitive and is a tad more robust: for file in *.csv; do cat $file >> newfile; done Can... (2 Replies)
Discussion started by: figaro
2 Replies

9. UNIX for Dummies Questions & Answers

Copying multiple directories at the same time using Unix

Another Unix question. How would I copy multiple directories at the same time? Right now I do: cp -r -f /directory1/ ../backup/directory1/ I do that for each directory one at a time. But there are multiple directories I'd like to copy. So instead of sitting there and doing one at a time, is... (9 Replies)
Discussion started by: JPigford
9 Replies

10. UNIX for Dummies Questions & Answers

Find wildcard .shtml files in wildcard directories and removing them- How's it done?

I'm trying to figure out how to build a small shell script that will find old .shtml files in every /tgp/ directory on the server and delete them if they are older than 10 days... The structure of the paths are like this: /home/domains/www.domain2.com/tgp/ /home/domains/www.domain3.com/tgp/... (1 Reply)
Discussion started by: Neko
1 Replies
Login or Register to Ask a Question