I have a file that outputs lines of the following form:
$XYZ blah blah blah
$XYZ something
$XYZ random data
The "$XYZ" prefix is the same for every line, it really does start with a dollar sign, and it's highly unlikely to occur anywhere but the start of a line.
The only way I can get at this file is via screen capture, which causes the lines to wrap at 80 characters. So it looks like the following (if you pretend wrapping is at a smaller number than 80):
$XYZ blah bl
ah blah
$XYZ somethi
ng
$XYZ random
data
I'd like to recreate the real lines from that. I could write a program to do it, but I'm thinking there might be some Unix command that I'm not familiar with that might make it easy. Any ideas?
Thanks in advance.
First, merge all the lines into one long line and then add a newline wherever you see the word which is supposed to be the start of a line, like this:
tr -d '\n' < file | sed 's/XYZ/\nXYZ/g'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With