当前时区 GMT+8, 现在时间是 2008-8-29 03:16 游客: 注册 登录 仅登录论坛 | 搜索 帮助
标题: the question about copy
sh225415
新手上路
Rank: 1


UID 89129
精华 0
积分 4
帖子 3
阅读权限 10
注册 2004-1-13
来自 China.gif
状态 离线
发表于 2007-7-4 18:23  资料  短消息  加为好友  添加 sh225415 为MSN好友 通过MSN和 sh225415 交谈
the question about copy

I want to copy one file to different folders at the same time. Can somebody tell me how to deal with it ?
For example, copy "hf.txt" to f01, f02, f03,... f99.
Thanks a lot!

顶部
BOoRFGOnZ
公社版主




UID 79089
精华 11
积分 14781
帖子 7832
阅读权限 225
注册 2003-11-30
来自 Linux World
状态 离线
发表于 2007-7-5 12:18  资料  短消息  加为好友 
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
so you can do like this
find <start_directory>  -exec cp {} \;





Weiwei加油   我要追三顺!
顶部
sh225415
新手上路
Rank: 1


UID 89129
精华 0
积分 4
帖子 3
阅读权限 10
注册 2004-1-13
来自 China.gif
状态 离线
发表于 2007-7-6 17:56  资料  短消息  加为好友  添加 sh225415 为MSN好友 通过MSN和 sh225415 交谈
回复 #2 BOoRFGOnZ 的帖子

Thank you for your help. But I want to copy one source to multiple directories at the same time. Is it possible ?

顶部
secpoint
中级会员
Rank: 3Rank: 3


UID 57998
精华 1
积分 656
帖子 298
阅读权限 30
注册 2003-8-29
来自 China
状态 离线
发表于 2007-7-6 20:55  资料  短消息  加为好友  添加 secpoint 为MSN好友 通过MSN和 secpoint 交谈 QQ
Please try this cmd

find . -name "f[0-9][1-9]" -type d -print -exec cp hf.txt {} \;

note:
. :is current directory
-type d :means only find directory
-print : You should use this when use -exec
{} \;  :You should  put these at end of command line when use -exec and there is a blank between } and \.

[ 本帖最后由 secpoint 于 2007-7-6 21:08 编辑 ]





滴水成河,聚沙成塔。
顶部
bigapple2008
新手上路
Rank: 1



UID 119057
精华 0
积分 60
帖子 24
阅读权限 10
注册 2004-4-26
来自 China
状态 离线
发表于 2007-7-8 10:28  资料  短消息  加为好友  添加 bigapple2008 为MSN好友 通过MSN和 bigapple2008 交谈 QQ
CPU will run the command one by one, so you never do 2 or more things at the same time.





bigapple --------------- 浙江工业大学校园联络员
顶部
gucuiwen
高级会员
Rank: 4


UID 13483
精华 14
积分 1124
帖子 428
阅读权限 50
注册 2003-1-20
来自 China
状态 离线
发表于 2007-8-7 14:54  资料  短消息  加为好友 
for dest in `seq -w 99`
do
   cp hf.txt f${dest}
done





--我:其实,我是一个linux系统管理员! --柏芝:你不就是一个死搞电脑的嘛! --我:小姐,就算你要说我是一个搞电脑的,也请不要在前面加一个"死"字. windows是一头性格温顺的驴,每个人都可以顺顺当当的骑上去,但是它跑不快,跑不远. linux是一匹性格很烈的野马,不是说想骑就骑的,但是一旦你摸到了他的脾性,可以驾驭它的时候,他比任何驴都跑的快. 也能给你带来驰骋的感觉
顶部
 


Powered by Discuz! 5.5.0  © 2001-2007 Comsenz Inc.
清除 Cookies - 联系我们 - 中国Linux公社 - WAP