|
|
A pattern range consists of two patterns separated by a comma, as in
pat[1], pat[2] { . . . }In this case, the action is performed for each line between an occurrence of pat[1] and the next occurrence of pat[2] (inclusive). For example, the pattern
/Canada/, /Brazil/matches lines starting with the first line that contains the string Canada up through the next occurrence of the string Brazil:
Similarly, since FNR is the number of the current record in the current input file (and FILENAME is the name of the current input file), the program
FNR == 1, FNR == 5 { print FILENAME, $0 }prints the first five records of each input file with the name of the current input file prepended.