我有一个文件:
@Book{gjn2011ske,
author = {Grzegorz J. Nalepa},
title = {Semantic Knowledge Engineering. A Rule-Based Approach},
publisher = {Wydawnictwa AGH},
year = 2011,
address = {Krak\'ow}
}
@article{gjn2010jucs,
Author = {Grzegorz J. Nalepa},
Journal = {Journal of Universal Computer Science},
Number = 7,
Pages = {1006-1023},
Title = {Collective Knowledge Engineering with Semantic Wikis},
Volume = 16,
Year = 2010
}
我想改进只删除第一行的正则表达式。注意:记录分隔符RS="}\n"
不能更改。
我试过:
awk 'BEGIN{ RS="}\n" } {gsub(/@.*,/,"") ; print }' file
我想打印结果:
author = {Grzegorz J. Nalepa},
title = {Semantic Knowledge Engineering. A Rule-Based Approach},
publisher = {Wydawnictwa AGH},
year = 2011,
address = {Krak\'ow}
Author = {Grzegorz J. Nalepa},
Journal = {Journal of Universal Computer Science},
Number = 7,
Pages = {1006-1023},
Title = {Collective Knowledge Engineering with Semantic Wikis},
Volume = 16,
Year = 2010
感谢您的帮助。
编辑:
我提出的解决方案:
awk 'BEGIN{ RS="}\n" }{sub(",","@"); sub(/@.*@/,""); print }' file