我正在尝试找到一种方法来选择性地从文件中删除换行符。删除所有这些我没有问题..但我需要留下一些。
这是错误输入文件的示例。请注意,许可证 ID COO789 和 COO012 的行在我需要删除的描述字段中嵌入了换行符。
"Permit Id","Permit Name","Description","Start Date","End Date"
"COO123","Music Festival",,"02/12/2013","02/12/2013"
"COO456","Race Weekend",,"02/23/2013","02/23/2013"
"COO789","Basketball Final 8 Championships - Media vs. Politicians
Skills Competition",,"02/22/2013","02/22/2013"
"COO012","Dragonboat race
weekend",,"05/11/2013","05/11/2013"
这是我需要文件看起来如何的示例:
"Permit Number/Id","Permit Name","Description","Start Date","End Date"
"COO123","Music Festival",,"02/12/2013","02/12/2013"
"COO456","Race Weekend",,"02/23/2013","02/23/2013"
"COO789","Basketball Final 8 Championships - Media vs. Politicians Skills Competition",,"02/22/2013","02/22/2013"
"COO012","Dragonboat race weekend",,"05/11/2013","05/11/2013"
注意:我确实通过删除一些额外的列来简化文件。不过,逻辑应该能够容纳任意数量的列。实际的完整标题行包含所有列。从技术上讲,我希望在描述和位置列中找到“额外的”换行符。
"Permit Number/Id","Permit Name","Description","Start Date","End Date","Custom Status","Owner Name","Total Expected Attendance","Location"
我尝试过 sed、cut、tr、nawk 等。对任何可以做到这一点的解决方案都开放......可以从 unix 脚本中调用。
谢谢!!!