Join a line beginning with a space with the line above in a file [closed]

I have a file that has lines and lines that start with spaces. If the line starts with a space I need it joined with the line above.

A file containing:

;laskdfj;lakdjfasldkjfeifoaiewiojefafewioewj
 ;alksdjfljadlfkjafld;j
 la;ksdjfl;aksdjflkasdjfalsjdkljdf

eiojeaojewfjdlkfjwoieur2oe3rj3o
 owaeijfoawjijefawoajeij

should end up:

;laskdfj;lakdjfasldkjfeifoaiewiojefafewioewj;alksdjfljadlfkjafld;jla;ksdjfl;aksdjflkasdjfalsjdkljdf

eiojeaojewfjdlkfjwoieur2oe3rj3oowaeijfoawjijefawoajeij

  • Well, when I submitted it, there was a hard return and a space on the upper 2 lines. The editor put them together split by a space. Let me try it here: My first line here fol lowed by more for the first line My second line here followed by mor e characters that need to go with th e first line and such…

    – 




  • Yeah, hope you get it because the editor won’t allow me to display it correctly…

    – 

  • Let me just explain. The file was created with the premise that only a certain amount of characters are allowed on a line. If there are more characters, the next line starts with a space as an indicator that it is a part of the previous line. This can continue for several lines worth of characters. I want to join them together. Thanks!

    – 

  • 1

    All those details should be in the question, not comments. I’ve fixed the formatting for you.

    – 

  • 3

    idownvotedbecau.se/noattempt – Please show what you tried, and we’ll offer suggestions and solutions. See this guide on asking good questions. Also – you want to preserve the empty line between records?

    – 




Leave a Comment