The print Command
The print command is used to output text. The output text is always terminated with a predefined string called the output record separator (ORS) whose default value is a newline. The simplest form of this command is:
print- This displays the contents of the current record. In AWK, records are broken down into fields, and these can be displayed separately:
print $1- Displays the first field of the current record
print $1, $3- Displays the first and third fields of the current record, separated by a predefined string called the output field separator (OFS) whose default value is a single space character
Although these fields ($X) may bear resemblance to variables (the $ symbol indicates variables in Perl), they actually refer to the fields of the current record. A special case, $0, refers to the entire record. In fact, the commands "print" and "print $0" are identical in functionality.
The print command can also display the results of calculations and/or function calls:
print 3+2 print foobar(3) print foobar(variable) print sin(3-2)Output may be sent to a file:
print "expression" > "file name"or through a pipe:
print "expression" | "command"Read more about this topic: AWK, AWK Commands
Famous quotes containing the word command:
“An actor must communicate his authors given messagecomedy, tragedy, serio- comedy; then comes his unique moment, as he is confronted by the looked-for, yet at times unexpected, reaction of the audience. This split second is his; he is in command of his medium; the effect vanishes into thin air; but that moment has a power all its own and, like power in any form, is stimulating and alluring.”
—Eleanor Robson Belmont (18781979)