Reputation: 31
I have data in particular format, Where my data is breaking with the lines after a + character and I need in a single line
ABC|def|ghi+
|jkl|mno
XYZ|pqr|lmn+
|qrr|stv
EXPECTED OUTPUT:
ABC|def|ghi|jkl|mno
XYZ|pqr|lmn|qrr|stv
Upvotes: 0
Views: 29
Reputation: 247012
Here's a technique with awk:
awk '/\+$/ {printf "%s", substr($0, 0, length($0)-1); next}; 1' file
For lines that end with a plus, print the line (minus the plus) without a newline.
For other lines, print with a newline.
Upvotes: 1