Description
In the datafile:
- Every three non-blank lines constitute a data record.
- Non-blank lines may be separated by none, one or more blank lines.
What we want is joining lines constitute a data record to one line,
separating them by '|'s.
|
| Raw Input
|
| Desired Output
| John Doe
123 Main St
Anytown, CT 06203
Mickey Mouse
11223 132nd Ave
Anaheim, CA 91004
Alfred E Neumann
47 Ironic Drive
Intercourse, PA 09342
|
| John Doe|123 Main St|Anytown, CT 06203
Mickey Mouse|11223 132nd Ave|Anaheim, CA 91004
Alfred E Neumann|47 Ironic Drive|Intercourse, PA 09342
|
|
Script and Comments
Script1 [ 1] /^$/d
[ 2] :loop
[ 3] N
[ 4] /^([^\n]+\n+){2}[^\n]/!b loop
[ 5] s/\n+/|/g
| |