Библиотека сайта rus-linux.net
Multiple sed commands can be put in a file and executed using the
-f option. When creating such a file, make sure that:
No trailing white spaces exist at the end of lines.
No quotes are used.
When entering text to add or replace, all except the last line end in a backslash.
Writing output is done using the output redirection operator >. This is an example script used to create very simple HTML files from plain text files.
$1 holds the first argument to a given command, in this case the name of the file to convert:
More on positional parameters in Chapter 7.
This is not really how it is done; this example just demonstrates sed capabilities. See Section 6.3 for a more decent solution to this problem, using awk BEGIN and END constructs.
Advanced editors, supporting syntax highlighting, can recognize sed syntax. This can be a great help if you tend to forget backslashes and such.