【发布时间】:2014-05-07 08:15:55
【问题描述】:
我正在尝试编写一个命令 (sed/awk) 在以下条件下用破折号替换换行符:
这不应被替换为破折号,因为 CSV 中没有新行:
X00000;111111;1111111111;This is just a text
无论如何,在这个例子中,新行应该用破折号代替:
X00000;111111;1111111111;This is a longer text which contains a
new line sign.
替换的输出应该是这样的:
X00000;111111;1111111111;This is a longer text which contains a - new line sign.
编辑:这也应该适用于这样的行:
X00000;111111;1111111111;"This is a longer text which contains a
new line sign
or even more
or a line that even contains only a new line sign
"
在这种情况下,预期会出现以下输出:
X00000;111111;1111111111;"This is a longer text which contains a - new line sign - or even more - - or a line that even contains only a new line sign - "
【问题讨论】:
-
CSV 中的列数是否固定为 4?换行符可以在任何地方吗?可以有多个换行符吗?
-
是的,列数固定为4,换行只能在最后一列。谢谢
-
请发布预期输出。空行应该就像
- - -