print
[ output-expr[, ...]] [ dest-expr ]Evaluate the output-expr and direct it to standard output, followed by the value of ORS
. Each comma-separated output-expr is separated in the output by the value of OFS
. With no output-expr, print $0
.
dest-expr is an optional expression that directs the output to a file or pipe.
>
fileDirects the output to a file, overwriting its previous contents.
>>
fileAppends the output to a file, preserving its previous contents. In both cases, the file is created if it does not already exist.
|
commandDirects the output as the input to a Unix command.
Be careful not to mix >
and >>
for the same file. Once a file has been opened with >
, subsequent output statements continue to append to the file until it is closed.
Remember to call close()
when you have finished with a file or pipe. If you don't, eventually you will hit the system limit on the number of simultaneously open files.