This section describes a gawk
-specific feature.
Normally, when you send data down a pipeline to a command with
print
or printf
, gawk
flushes the
output down the pipe. That is, output is not buffered, but
written directly. This assures, that pipeline output
intermixed with gawk
’s output comes out in the
expected order:
print "something" # goes to standard output print "something else" | "some-command" # also to standard output print "more stuff" # and this too
There can be a price to pay for this; flushing data down the pipeline uses more CPU time, and in certain environments this can become expensive.
You can tell gawk
not to flush buffered data in
one of two ways:
PROCINFO["BUFFERPIPE"]
to any value. When this is done,
gawk
will buffer data for all pipelines.
PROCINFO["command", "BUFFERPIPE"]
to any value.
In this case, only command’s data will be fully buffered.
You must create one or the other of these elements
in PROCINFO
before the first print
or
printf
to the pipeline. Doing so after output has
already been sent is too late.
Be aware that using this feature may change the output behavior of your programs, so exercise caution.