www.delorie.com/gnu/docs/gawk/gawk_95.html   search  
Buy the book!

The GNU Awk User's Guide

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.1 Pattern Elements

7.1.1 Regular Expressions as Patterns  Using regexps as patterns.
7.1.2 Expressions as Patterns  Any expression can be used as a pattern.
7.1.3 Specifying Record Ranges with Patterns  Pairs of patterns specify record ranges.
7.1.4 The BEGIN and END Special Patterns  Specifying initialization and cleanup rules.
7.1.5 The Empty Pattern  The empty pattern, which matches every record.

Patterns in awk control the execution of rules--a rule is executed when its pattern matches the current input record. The following is a summary of the types of awk patterns:

/regular expression/
A regular expression. It matches when the text of the input record fits the regular expression. (See section Regular Expressions.)

A single expression. It matches when its value is nonzero (if a number) or non-null (if a string). (See section Expressions as Patterns.)

pat1, pat2
A pair of patterns separated by a comma, specifying a range of records. The range includes both the initial record that matches pat1 and the final record that matches pat2. (See section Specifying Record Ranges with Patterns.)

Special patterns for you to supply startup or cleanup actions for your awk program. (See section The BEGIN and END Special Patterns.)

The empty pattern matches every input record. (See section The Empty Pattern.)

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003