我有一个带有以下给定示例的文本文件。
M00214180|M0021418000|00|10007702|153203136600|1|M|02||10232015
M00214180|M0021418000|00|10007702|153203136600|2|M|02||10232015
M00214180|M0021418000|00|10007702|153203429000|1|M|02||10232015
M00214178|M0021417801|01|10007702|153010126800|1|M|02||05122015
M00214163|M0021416301|01|10007702|153080107000|1|M|02||10302015
但它应该如下:
M00214180|M0021418000|00|10007702|153203136600|1|M|02| |10232015
M00214180|M0021418000|00|10007702|153203136600|2|M|02| |10232015
M00214180|M0021418000|00|10007702|153203429000|1|M|02| |10232015
M00214178|M0021417801|01|10007702|153010126800|1|M|02| |05122015
M00214163|M0021416301|01|10007702|153080107000|1|M|02| |10302015
答案 0 :(得分:2)
使用此
sed 's/||/| |/g' your_file.txt
如果您的文件只出现两个相邻分隔符,则可以省略g
部分,如下所示。
sed 's/||/| |/' your_file.txt