awk - 如果下一行以单词字符开头,则用空格替换新行
问题描述
我有一个看起来像的大文本文件
some random : demo text for
illustration, can be long
and : some more
here is : another
one
我想要一个像这样的输出
some random : demo text for illustration, can be long
and : some more
here is : another one
我尝试了一些奇怪的,明显错误的正则表达式,%s/\w*\n/ /g
但无法真正理解。
解决方案
使用您显示的示例,请尝试以下awk
代码。使用 RS(记录分隔符),将其设置为无效。这仅基于您显示的示例。
awk -v RS="" '{$1=$1} 1' Input_file
推荐阅读
- python - Python unittest 断言复杂字典
- performance - JMeter 脚本开发
- php - WooCommerce — 格式化尺寸
- php - 在 whm cpanel 上部署 laravel 5.6.12 时出错
- javascript - 如何使用 jQuery 模拟输入事件?
- wordpress - woocommerce支付错误
- python - 如何按出现次数排序,以及出现次数是否按字母顺序排序?
- go - 如何将指针的值从映射传递到函数参数
- java - 我想制作一个可以将视频作为字节流并保存的服务器
- javascript - 在 Javascript 中是否可以创建具有动态(未确定)属性/成员的对象?