13.7.1. Program Notes for gent
Once you get used to reading awk scripts, they seem so much easier
to understand than all but the simplest sed script. It can
be a painstaking task to figure out what a small sed script
like the one shown here is doing.
This script does show how to pass shell variables into a sed
script. Variables are used to pass optional sed commands into
the script, such as the substitution commands that replace
backslashes and spaces.
This script could be simplified in several ways.
First of all, the two regular expressions don't seem
necessary to match the entry. The first matches the
name of the entry at the beginning of a line; the second
matches it elsewhere on the line.
The loops labeled x and y
are identical and even if the two regular expressions were
necessary, we could have them branch to the same loop.