An example using the '$' address, mentioned in the quote by Carpetsmoker from the FreeBSD sed(1) man page:
Code:
$ cat animal.sed
1 {
i\
A list of animals in our zoo\
----------------------------
}
$ {
a\
==== END of LIST ====
}
A sample file
Code:
$ cat animal.txt
giraffe
lion
elephant
The result:
Code:
$ sed -f animal.sed animal.txt
A list of animals in our zoo
----------------------------
giraffe
lion
elephant
==== END of LIST ====
Now we will use a second file
Code:
$ cat animal2.txt
ostrich
hyena
gorilla
Telling sed(1) to process both files
Code:
$ sed -f animal.sed animal*.txt
A list of animals in our zoo
----------------------------
giraffe
lion
elephant
ostrich
hyena
gorilla
==== END of LIST ====
So this a simulation of the behaviour of the GNU/FreeBSD
-I option by OpenBSD's sed.
The
-i flag equivalent would be
Code:
$ sed -f animal.sed animal.txt ; sed -f animal.sed animal2.txt
A list of animals in our zoo
----------------------------
giraffe
lion
elephant
==== END of LIST ====
A list of animals in our zoo
----------------------------
ostrich
hyena
gorilla
==== END of LIST ====
Note: for readability some whitespace added.