Each line of input is copied into a “pattern space,”
an internal buffer where editing operations are performed.
All editing commands in a sed script are applied,
in order, to each line of input.
Editing commands are applied to all lines (globally) unless line
addressing restricts the lines affected.
If a command changes the input, subsequent commands and address tests
are applied to the current line in the pattern space, not the original
input line.
The original input file is unchanged because the editing commands modify
a copy of each original input line. The copy is sent to standard output
(but can be redirected to a file).
sed also maintains the “hold space,”
a separate buffer that can be used to save data for later retrieval.