I want to pretty up some output from scripts running RSYNC. I am trying to achieve the following transformation:
Code:
task: syncing directory /var to host 192.168.1.1
cache/g/idx.db
ce/p70/events.hmm
task: syncing directory /tmp to host 192.168.1.100
s/t/eak.fry
Code:
task: syncing directory /var to host 192.168.1.1
192.168.1.1:/var/cache/g/idx.db
192.168.1.1:/var/ce/p70/events.hmm
task: syncing directory /tmp to host 192.168.1.100
192.168.1.100:/tmp/s/t/eak.fry
So you form a string with IP:/dir/ where IP and dir are pulled from headers of the form:
task: syncing directory /dir to host IP
Then you insert that IP:/dir/ string before every filename, on all the lines until the next header is encountered.
By the way, it would be OK to remove the header lines along the way, I'll have to do that anyway.
I can't bend my mind around some of the advanced sed syntax, using the hold buffer. I would be very grateful if you have any idea how to do this.