Answers to Part 2 Exercises

Solution to ``EXPORT'' Problem

Typing:


1 ; ?EXPORT? delete

will do it. By starting from the first line in the file and searching backwards, you guarantee the the first line to be searched will be the last line of the file (due to wraparound), then the second-to-last line, etcetera. As soon as the editor finds a match it stops, so there cannot be another ``EXPORT'' lower down in the file.

Back to the question


Solution to First-Line Problem

This requires two commands:


$ print
/EXPORT/ delete

The first command prints the last line in the file, which is not helpful in itself, but also leaves that last line as the current line. Then, the address of the second command causes a forward search and, due to wraparound, the search must begin with the file's first line.

Back to the question


Solution to Noninclusive Problem

Just add a plus sign after the address before the comma, and a minus sign to the address after it, like this:


?abc? + , /xyz/ -

Each of these offsets moves one line toward the center of the text section the combined address specifies, so each has the effect of leaving out the line where the match was found. (That the first search was backward and the second forward is not relevant. The point is that the address before the comma, whatever it is, receives the plus offset, while the address after the comma gets the minus offset.)

Back to the question


Back to the index