Description
Each complete record consists of 3 consecutive lines whose tags are
Header:,
Category:, and
Title:, respectively.
When processing a datafile,
we want to retrieve complete records and discard lines
not belonging to any complete record.
|
| Raw Input
|
| Desired Output
| Header: 1
Category: Algorithm
Title: Algorithms in C
Header: 2
Header: 3
Title: Making TeX Work
Category: Publication
Header: 4
Category: Shell Programming
Title: Learning the Bash Shell
|
| Header: 1
Category: Algorithm
Title: Algorithms in C
Header: 4
Category: Shell Programming
Title: Learning the Bash Shell
|
|
Script and Comments
Script1 [ 1] /^Header:/!d
[ 2] $!N
[ 3] /\nCategory:/!d
[ 4] $!N
[ 5] /\nTitle:/!d
[ 6] s/$/\n/
| |