1 1 7.1 Pattern Elements 1 ==================== 1
1 · Regexp Patterns Using regexps as patterns. · Expression Patterns Any expression can be used as a pattern. · Ranges Pairs of patterns specify record ranges. · BEGIN/END Specifying initialization and cleanup rules. · BEGINFILE/ENDFILE Two special patterns for advanced control. · Empty The empty pattern, which matches every record. 1 1 Patterns in 'awk' control the execution of rules--a rule is executed 1 when its pattern matches the current input record. The following is a 1 summary of the types of 'awk' patterns: 1 1 '/REGULAR EXPRESSION/' 1 A regular expression. It matches when the text of the input record 1 fits the regular expression. (⇒Regexp.) 1 1 'EXPRESSION' 1 A single expression. It matches when its value is nonzero (if a 1 number) or non-null (if a string). (⇒Expression Patterns.) 1 1 'BEGPAT, ENDPAT' 1 A pair of patterns separated by a comma, specifying a "range" of 1 records. The range includes both the initial record that matches 1 BEGPAT and the final record that matches ENDPAT. (⇒Ranges.) 1 1 'BEGIN' 1 'END' 1 Special patterns for you to supply startup or cleanup actions for 1 your 'awk' program. (⇒BEGIN/END.) 1 1 'BEGINFILE' 1 'ENDFILE' 1 Special patterns for you to supply startup or cleanup actions to be 1 done on a per-file basis. (⇒BEGINFILE/ENDFILE.) 1 1 'EMPTY' 1 The empty pattern matches every input record. (⇒Empty.) 1