I'm currently writing a bash script for parsing a simple text file. I now have the problem that there are a few occurences of new lines, where none should be. Let me give you an example
Q1bcd 3 - 4 --- --- --- Ba Klasse hat Aufgab..
8 a 3 --- --- Mr
6 b 3 - 4 --- --- --- Bu Unterricht im
Klassenverband
8 a 4 --- --- Ke
7 a 4 De Bi r24 La
The 'Klassenverband' string is in a new line. I don't want that. To remove the new line character I tried different commands with sed and awk:
awk '/^\([a-zA-Z]\{4\}\)/{printf "%s ",$0;next} 1' file
sed '/^\([a-zA-Z]\{4\}\)/{N;s/\n//;}' file
What I've come up with so far, is that all the neccecary strings can be extracted with the following Regex
^\([a-zA-Z]\{4\}\)
I am expecting an output like this
Q1bcd 3 - 4 --- --- --- Ba Klasse hat Aufgab..
8 a 3 --- --- Mr
6 b 3 - 4 --- --- --- Bu Unterricht im Klassenverband
8 a 4 --- --- Ke
7 a 4 De Bi r24 La
Edit: This worked for me. But the text file needs to be a unix text file no DOS file
sed '$!N; s/\n\([[:alpha:]]\{4,\}\)/ \1/; P;D' file