Raw Input
The input file contains several multi-line records.
Each record consists of
  • a tag line indicating the date in the form 'Date: MM/DD/YYYY', and
  • one or more data lines.
Empty lines are ignored.
The datafile is:
Date: 05/01/2001
record1
record2
Date: 05/02/2001
record1
record2
record3
Date: 05/04/2001
record1
Desired Output
What we want is prepending the tag line to every data line belonging to that date.
The desired outupt is:
05/01/2001,record1
05/01/2001,record2
05/02/2001,record1
05/02/2001,record2
05/02/2001,record3
05/04/2001,record1
Script and Comments
Script1
[ 1] /^Date: /{
[ 2] s/^Date: //
[ 3] x
[ 4] d
[ 5] }
[ 6] /^$/d
[ 7] G
[ 8] s/^\(.*\)\n\(.*\)/\2,\1/