免费注册 查看新帖 |

Chinaunix

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

AWK 转换文件 的问题。 求助 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-06-30 16:28 |只看该作者 |倒序浏览
Could anyone tell me the basic idea for dealing this question?
The question is reformat  a text into an XML-styled format.

Once upon a midnight <TAB> dreary, while I pondered weak and weary,
Over many a quaint and curious volume of<Tab>forgotten lore,       

become:

<row>
<entry>Once upon a midnight</entry>
<entry>dreary, while I pondered weak and weary,</entry>
</row>
<row>
<entry>Over many a quaint and curious volume of<entry</entry>
<entry>forgotten lore,        </entry>
<row>

I am consider by reading per character,  tab separated and line feed should be the case.
How can I detect it is a tab separated and it is going to create a new line in awk ?

note: <TAB> is tab separated. this forums ignore tap.

论坛徽章:
0
2 [报告]
发表于 2010-06-30 16:31 |只看该作者
把文中 那段文字
Once upon a midnight<Tags>dreary, while I pondered weak and weary,
Over many a quaint and curious volume of<Tags>forgotten lore,
通过编制一个awk 转换成
     
<row>
<entry>Once upon a midnight</entry>
<entry>dreary, while I pondered weak and weary,</entry>
</row>
<row>
<entry>Over many a quaint and curious volume of<entry</entry>
<entry>forgotten lore,        </entry>
<row>

这样的形式

论坛徽章:
34
亥猪
日期:2015-03-20 13:55:11戌狗
日期:2015-03-20 13:57:01酉鸡
日期:2015-03-20 14:03:56未羊
日期:2015-03-20 14:18:30子鼠
日期:2015-03-20 14:20:14丑牛
日期:2015-03-20 14:20:31辰龙
日期:2015-03-20 14:35:34巳蛇
日期:2015-03-20 14:35:56操作系统版块每日发帖之星
日期:2015-11-06 06:20:00操作系统版块每日发帖之星
日期:2015-11-08 06:20:00操作系统版块每日发帖之星
日期:2015-11-19 06:20:00黄金圣斗士
日期:2015-11-24 10:43:13
3 [报告]
发表于 2010-06-30 17:42 |只看该作者
把行首行尾分别换成特定标志,再给中间加上分隔。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP