If you are starting out to learn sed and awk, you can benefit from looking at how much they have in common.
They are invoked using similar syntax.
They are both stream-oriented, reading input from text files one line at a time and directing the result to standard output.
They use regular expressions for pattern matching.
They allow the user to specify instructions in a script.
One reason they have so much in common is that their origins can be found in the same line editor, ed. In this chapter, we begin by taking a brief look at ed and show how sed and awk were logical steps towards the creation of a programmable editor.
Where sed and awk differ is in the kind of instructions that control the work they do. Make no mistake—this is a major difference, and it affects the kinds of tasks that can best be performed with these programs.
This chapter looks at the command-line syntax of sed and awk and the basic structure of scripts. It also offers a tutorial, using a mailing list, that will give you a taste of script writing. It is valuable to see sed and awk scripts side-by-side before you concentrate on either one of them.