我有一个带有随机换行符的文本文件。所有新行都以“客户”一词开头。如何删除第二行和第三行末尾的多余换行符?
client | This is first row | 2013-02-01 23:45:59 | last column
clientd | second row with a line break
third line part of row 2 | 2013-01-31 12:44:00 | last column
client xyz | some text here | 2013-12-21
12:54:12 | last column
预期结果:
client | This is first row | 2013-02-01 23:45:59 | last column
clientd | second row with a line break third line part of row 2 | 2013-01-31 12:44:00 | last column
client xyz | some text here | 2013-12-21 12:54:12 | last column
sed 命令有效,但如果可能的话,我正在寻找任何改进。
cat test.txt | tr '\n' ' ' | sed 's/client/\nclient/g'
还有其他方法可以实现吗?