As each line of input is read, the program reads the first instruction
in the script and checks the pattern
against the current line. If there is no match, the
procedure is ignored and the next
instruction is read. If there is a match, then the action or actions
specified in the procedure are followed.
All of the instructions are read, not just the first instruction that
matches the input line.
When all the applicable instructions have been interpreted and applied
for a single line, sed outputs the line and repeats the cycle for each
input line. Awk, on the other hand, does not
automatically output the line; the instructions
in your script control what is finally done with it.
The contents of a procedure are very different in sed and awk. In
sed, the procedure consists of editing commands like those used in the
line editor. Most commands consist of a single letter.
In awk, the procedure consists of programming statements and
functions. A procedure must be surrounded by braces.
In the sections that follow, we'll look at a few scripts that process
a sample mailing list.