Artificial intelligent assistant

AWK - Add previous line to beginning of next two lines I have a document that looks like this: Bob: This is my line This is also my line Alfred: What a great day! What should we do! Jess: Its so hot Lets go to the Beach The format is always the same, it's always speaker line1 line2 speaker line1 line2 There is never additional lines, etc. I want the 'speaker' to be at the beginning of every line, so in my example it is: Bob: This is my line Bob: This is also my line Alfred: What a great day! Alfred: What should we do! Jess: Its so hot Jess: Lets go to the Beach I've tried extracting every 'nth' line using awk awk '{if (NR % 3 == 1) print $0}' but I'm not sure how to add it back to the beginning of the next two lines. Thanks for your help

awk 'NR%3==1{ name=$0; next } { print name, $0 }' file


If the condition is true, save the record to variable `name` and continue with the `next` record.

Print `name` and current record otherwise.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy dd68cb79eaa39562eb3e019bdedfc1af