gawk provides the
which is similar to the
However, instead of abandoning processing of the current record, the
nextfile statement instructs
gawk to stop processing the
current data file.
Upon execution of the
updated to the name of the next data file listed on the command line,
FNR is reset to one,
ARGIND is incremented, and processing
starts over with the first rule in the progam. See section Built-in Variables.
nextfile statement causes the end of the input to be reached,
then the code in any
END rules will be executed.
See section The
END Special Patterns.
nextfile statement is a
gawk extension; it is not
(currently) available in any other
See section Implementing
nextfile as a Function,
for a user-defined function you can use to simulate the
nextfile statement would be useful if you have many data
files to process, and you expect that you
would not want to process every record in every file.
Normally, in order to move on to
the next data file, you would have to continue scanning the unwanted
nextfile statement accomplishes this much more
Caution: Versions of
gawk prior to 3.0 used two
words (`next file') for the
nextfile statement. This was
changed in 3.0 to one word, since the treatment of `file' was
inconsistent. When it appeared after
next, it was a keyword.
Otherwise, it was a regular identifier. The old usage is still
gawk will generate a warning message, and
next file will eventually be discontinued in a
future version of
Go to the first, previous, next, last section, table of contents.