home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeLinux in a NutshellSearch this book

13.3. Patterns and Procedures

gawk scripts consist of patterns and procedures:

pattern  {procedure}

Both are optional. If pattern is missing, {procedure} is applied to all records. If {procedure} is missing, the matched record is printed. By default, each line of input is a record, but you can specify a different record separator through the RS variable.

13.3.1. Patterns

A pattern can be any of the following:

/regular expression/
relational expression
pattern-matching expression
pattern,pattern
BEGIN
END

Some rules regarding patterns include:

Except for BEGIN and END, patterns can be combined with the Boolean operators || (OR), && (AND), and ! (NOT).

In addition to other regular-expression operators, GNU awk supports POSIX character lists, which are useful for matching non-ASCII characters in languages other than English. These lists are recognized only within [ ] ranges. A typical use would be [[:lower:]], which in English is the same as [a-z]. See Chapter 9, "Pattern Matching" for a complete list of POSIX character lists.



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.











??????????????@Mail.ru