免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 1489 | 回复: 10
打印 上一主题 下一主题

我有个难题:在一个文件夹里有这样一些文件: [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-08-02 14:55 |只看该作者 |倒序浏览
我有个难题:在一个文件夹里有这样一些文件:
文件夹里:   
Lihong_pro.txt  Lihong_score.txt
Wangwei_pro.txt  Wangwei_score.txt  
Lili_pro.txt  Lili_score.txt  
Maming_pro.txt  Maming_score.txt  
Tianhai_pro.txt  Tianhai_score.txt  
......
我们不知道有多少个这样XXX__pro.txt  XXX_score.txt  的文件,但只道它们是这样成双成对的,编个程序让所有的一对都合成一个个:

Lihong_total.txt   
Wangwei_total.txt   
Lili_total.txt  
Maming_total.txt   
Tianhai_total.txt   
........
(其中 cat Lihong_pro.txt  Lihong_score.txt >>Lihong_total.txt)然后每个文件再调用modify.pl 处理再存入各个
Lihong_result.txt   
Wangwei_result.txt   
Lili_result.txt  
Maming_result.txt   
Tianhai_result.txt   
........

论坛徽章:
0
2 [报告]
发表于 2003-08-02 15:22 |只看该作者

我有个难题:在一个文件夹里有这样一些文件:

这个不是很难,我觉得是你自己练手的一个机会。

论坛徽章:
0
3 [报告]
发表于 2003-08-02 15:31 |只看该作者

我有个难题:在一个文件夹里有这样一些文件:

有没有办法啊?请高手给露两手

论坛徽章:
0
4 [报告]
发表于 2003-08-02 16:00 |只看该作者

我有个难题:在一个文件夹里有这样一些文件:

#!/bin/sh
     
for i in `ls *_pro.txt | cut -d_ -f1`
do
        paste "$i"_pro.txt "$i"_score.txt > "$i"_total.txt
done

论坛徽章:
0
5 [报告]
发表于 2003-08-02 20:10 |只看该作者

我有个难题:在一个文件夹里有这样一些文件:

your code is wrong,  look at the result:
---------------------------------------------------
paste: Lihong_score.txt: No such file or directory
paste: Maming_score.txt: No such file or directory
paste: Tianhai_score.txt: No such file or directory
paste: Wangwei_score.txt: No such file or directory

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
6 [报告]
发表于 2003-08-03 00:03 |只看该作者

我有个难题:在一个文件夹里有这样一些文件:

  1. ls *_pro.txt|awk -F"_" '{printf"paste %s %s_score.txt >%s_total.txt\n",$0,$1,$1}'|sh
复制代码

论坛徽章:
0
7 [报告]
发表于 2003-08-03 00:12 |只看该作者

我有个难题:在一个文件夹里有这样一些文件:

Admire: GOOD JOB ! but your result has BUGS, look:
----------------------------------
Tianhai_pro.txtM-^?     Tianhai score
-------------------------------
why here has              M-^?

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
8 [报告]
发表于 2003-08-03 00:16 |只看该作者

我有个难题:在一个文件夹里有这样一些文件:

I'm Sorry!
try this:
  1. ls *_pro.txt|awk -F"_" '{printf"paste %s %s_score.txt >%s_total.txt\n",$0,$1,$1}'|sh
复制代码

or
  1. ls|sed -n 's/^\([^_]*\)_pro.txt$/paste & \1_score.txt \1_total.txt/p'|sh
复制代码

论坛徽章:
0
9 [报告]
发表于 2003-08-03 14:06 |只看该作者

我有个难题:在一个文件夹里有这样一些文件:

Admirer:  Your code still don't work and produce lots of strange things....

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
10 [报告]
发表于 2003-08-03 14:09 |只看该作者

我有个难题:在一个文件夹里有这样一些文件:

我是SCO UNIX执行结果没错!
你是从屏幕拷贝代码的吗?
请将执行错误代码贴出来!
   
  1. asdfgds_pro.txt
  2. asdfgds_score.txt
  3. asdfgds_total.txt
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP