sed/awk: How do I split a text stream (one line) into mulitple lines with different/varying lengths?
I have one file which contains a single one liner (text stream) that contains multiple lines/records.
Each line holds its full length in the first 5 chars.
Now I want to add a linebreak behind each line to separate them and get multiple lines.
00009test ( 9 chars: 5+4)
00011stream (11 chars: 5+6)
00006X ( 6 chars: 5+1)
000210123456789ABCDEF (21 chars: 5+16)
00005 ( 5 chars: 5+0)
My idea for sed was...
#1 get the first 5 chars as value
#2 backtrack to start of pattern
#3 print chars in the specified length plus newline
#4 start over at step #1, until nothing found
I have little experience with sed.
Tried to find a solution for #2 and #3 in the man pages and on the internet, but didn't get it.
Maybe awk could be a better option to achieve this.
Any help is greatly appreciated.