The UNIX Forums
"Join the Network of UNIX System Users"


 
Subject: copying to multiple directories using wildcard
arxidakas
Newbie
Rank: 1



UID 59
Digest Posts 0
Credits 0
Posts 42
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 19, 2007 01:43 PM  Profile | P.M. 
copying to multiple directories using wildcard



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 ?


Top
Remi
Newbie
Rank: 1



UID 22
Digest Posts 0
Credits 0
Posts 21
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 19, 2007 01:44 PM  Profile | P.M. 
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;
Top
karan265
Newbie
Rank: 1



UID 214
Digest Posts 0
Credits 0
Posts 78
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 19, 2007 01:44 PM  Profile | P.M. 
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
Top
darzuaga
Newbie
Rank: 1



UID 106
Digest Posts 0
Credits 0
Posts 50
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 19, 2007 01:44 PM  Profile | P.M. 
try this  

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

may be similar to previous post
Top
dynamike
Newbie
Rank: 1



UID 128
Digest Posts 0
Credits 0
Posts 40
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 19, 2007 01:45 PM  Profile | P.M. 
sorry small correction

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

 

All times are GMT, the time now is Jul 31, 2010 03:42 AM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.005490 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP