- 论坛徽章:
- 145
|
回复 15# funexploit
>> ...然后将执行结果赋值给一个变量
http://www.gnu.org/software/gawk/manual/gawk.html#Getline
4.9 Explicit Input with getline...
...
• Plain Getline: Using getline with no arguments.
• Getline/Variable: Using getline into a variable.
• Getline/File: Using getline from a file.
• Getline/Variable/File: Using getline into a variable from a file.
• Getline/Pipe: Using getline from a pipe.
• Getline/Variable/Pipe: Using getline into a variable from a pipe.
• Getline/Coprocess: Using getline from a coprocess.
• Getline/Variable/Coprocess: Using getline into a variable from a coprocess.
• Getline Notes: Important things to know about getline.
• Getline Summary: Summary of getline Variants.
...
4.9.6 Using getline into a Variable from a Pipe
When you use ‘command | getline var’, the output of command is sent through a pipe to getline and into the variable var. For example, the following program reads the current date and time into the variable current_time, using the date utility, and then prints it:
BEGIN {
"date" | getline current_time
close("date")
print "Report printed on " current_time
}
In this version of getline, none of the built-in variables are changed and the record is not split into fields. |
|