Go to the first, previous, next, last section, table of contents.
close(filename)
system(command)
awk program. The system function
executes the command given by the string command. It returns, as
its value, the status returned by the command that was executed.
For example, if the following fragment of code is put in your awk
program:
END {
system("mail -s 'awk run done' operator < /dev/null")
}
the system operator will be sent mail when the awk program
finishes processing input and begins its end-of-input processing.
Note that much the same result can be obtained by redirecting
print or printf into a pipe. However, if your awk
program is interactive, system is useful for cranking up large
self-contained programs, such as a shell or an editor.
Some operating systems cannot implement the system function.
system causes a fatal error if it is not supported.
system
Many utility programs will buffer their output; they save information
to be written to a disk file or terminal in memory, until there is enough
to be written in one operation. This is often more efficient than writing
every little bit of information as soon as it is ready. However, sometimes
it is necessary to force a program to flush its buffers; that is,
write the information to its destination, even if a buffer is not full.
You can do this from your awk program by calling system
with a null string as its argument:
system("") # flush output
Go to the first, previous, next, last section, table of contents.