sekhar sekhar - 2 months ago 6
Linux Question

How to remove new line character in a file without impact on the actual End of line in linux

I am having issue with New line character in a file which originates from an external source.The new line character impact is only for specific field @data5(shown below) and the application failing to read the format due to this.
Tried to remove it but its removing the actual End of the line as well.
Please let me know, how to remove new-line characters from in between a line without removing the new-line character from end of line.


Data displayed as below


data_1||data_2||data_3||data_4||data_5

||data_6||data_7||data_8||data_9

data_1||data_2||data_3||data_4||data_5

||data_6||data_7||data_8||data_9


Expected Output:

data_1||data_2||data_3||data_4||data_5||data_6||data_7||data_8||data_9
data_1||data_2||data_3||data_4||data_5||data_6||data_7||data_8||data_9

Thanks in Advance

sat sat
Answer

Using sed:

sed 'N;s/\n//' file
Comments