免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123
最近访问板块 发新帖
楼主: tasteoftime_90
打印 上一主题 下一主题

[文本处理] [已解决] 谢谢各位 请教多行内容合并一行输出 [复制链接]

论坛徽章:
0
21 [报告]
发表于 2014-08-15 10:00 |只看该作者
awk '{printf P$0=","}END{print""}' FILE
和awk '{printf $0 ","} END{print ""}' FILE
printf P$0="," 和 printf $0 "," 的差异在后者最后多了个逗号
可以稍微解释下吗回复 2# jason680


   

论坛徽章:
145
技术图书徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11狮子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龙
日期:2014-01-08 15:26:12技术图书徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
22 [报告]
发表于 2014-08-15 10:38 |只看该作者
回复 21# tasteoftime_90

printf P  $0;         P=","
printf $0 ",";   

1. printf P  $0;   P=","
  output the common(",") and full line
  Note: didn't have common(",") in first item
  Note: first time the variable P is empty

2. printf $0 ","
output full line and the common(",")
Note: always have common in the end

论坛徽章:
0
23 [报告]
发表于 2014-08-15 15:26 |只看该作者
相关的这些内容 哪里有介绍吗?回复 22# jason680


   

论坛徽章:
0
24 [报告]
发表于 2014-08-15 15:27 |只看该作者
谢谢!回复 22# jason680


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP