Description
The desired output file should satisfy the following requirements:
- It consists of 1-line records.
- Each record begins with 'RECORD', followd by one or more spaces,
then one or more fields separated by spaces.
Due to some typing errors, some records are split to multiple lines,
what we want to do is reformatting the file to satisfy the requirements.
The data file in 'wrong' and 'desired' formats are shown as follows:
|
| Raw Input
| RECORD data1.0 data1.1
data1.2
data1.3 data1.4
RECORD data2.0
data2.1 data2.2
data2.3
RECORD
data3.0 data3.1
data3.2
|
|
| Desired Output
| RECORD data1.0 data1.1 data1.2 data1.3 data1.4
RECORD data2.0 data2.1 data2.2 data2.3
RECORD data3.0 data3.1 data3.2
|
|
Script and Comments
Script1 [ 1] :loop
[ 2] N
[ 3] /\nRECORD/!{
[ 4] s/\n/ /
[ 5] b loop
[ 6] }
[ 7] P
[ 8] D
| |