Sams Teach Yourself Shell Programming (Web site hosting) in 24 Hours
Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 16: Filtering Text Using Regular Expressions Previous Chapter Next Chapter Sections in this Chapter: The Basics of awk and sed Summary Using sed Questions Previous Section Next Section Hour 16 Filtering Text Using Regular Expressions The most powerful text filtering tools in the UNIX environment are a pair of oddly named programs, awk and sed. They let shell programmers easily edit text files and filter the output of other commands using regular expressions. A regular expression is a string that can be used to describe several sequences of characters. sed (which stands for stream editor) was created as an editor exclusively for executing scripts. As its name implies, sed is stream oriented, thus all the input you feed into it passes through and goes to STDOUT. It does not change the input file. In this chapter I will show you how to use sed in shell scripts. I will cover awk programming in Chapter 17, “Filtering Text with awk,” but I’ll discuss some of the many similarities between awk and sed at the beginning of this chapter. The Basics of awk and sed Invocation Syntax Regular Expressions Basic Operation There are many similarities between awk and sed: l They have similar invocation syntax. l They enable you to specify instructions that execute for every line in an input file. l They use regular expressions for matching patterns . For those readers who are not familiar with patterns and regular expressions, I will explain them shortly. Invocation Syntax The invocation syntax for awk and sed is as follows: command ’script’ filenames Here command is either awk or sed, script is a list of commands understood by awk or sed, and filenames is a list of files that the command acts on.
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.