I'm trying to write script that partition very long text (one line) to multiple lines. The requirement is that every line must have prefixes with numbering. I tried using sed but I have problem with numbering matches. My code:
sed -e "s/.\{4\}/part = &\\
/g"
Input:
AAAAAAAAABBBBBBBAAAAAAABBBBBBB
Output:
part = AAAA
part = AAAA
part = ABBB
part = BBBB
part = AAAA
part = AAAB
part = BBBB
BB
Expected:
part1 = AAAA
part2 = AAAA
part3 = ABBB
part4 = BBBB
part5 = AAAA
part6 = AAAB
part7 = BBBB
part8 = BB
Additional problem is the last part that is not labeled. Is it possible to do it with sed? Or maybe any other shell tools?