Execution of a sed program
- When sed is started, it initializes the these buffers with «empty» content.
- Then sed iterates over each input line. Each new input line starts a cycle.
- During a cycle, all commands in the script whose addresses match the current input line are executed
- After executing all commands in the script, the content of the pattern space is printed is printed to STDOUT (unless the command line option
-n
was given)
- The pattern space (but not the hold space) is emptied and the next input line is read, which starts the next cycle