作者: chenbin200818 时间: 2011-03-06 19:25
无话可说 你还是找本书学习下把作者: kr_zhang 时间: 2011-03-06 19:36
我就是找不到才提问的。
我认为4行后应该输出,但输出2行,这2行也没规律作者: Shell_HAT 时间: 2011-03-06 19:37
The getline function is used to read another line of input. Not only can getline read from the
regular input data stream, it can also handle input from files and pipes.
The getline function is similar to awk's next statement. While both cause the next input line to be
read, the next statement passes control back to the top of the script. The getline function gets the
next line without changing control in the script.作者: Shell_HAT 时间: 2011-03-06 19:40 回复 3#kr_zhang
[oracle@Centos temp]$ awk -f a.awk tmp
aa bb cc dd
a b c d
! @ # $
aa bb cc dd
[oracle@Centos temp]$ cat a.awk
#!/bin/awk
{print ; getline var ; print var}
[oracle@Centos temp]$ cat tmp
aa bb cc dd
a b c d
! @ # $
aa bb cc dd
[oracle@Centos temp]$作者: ywlscpl 时间: 2011-03-07 08:41
每行都触发一次处理流程作者: kr_zhang 时间: 2011-03-07 08:54
{getline var;print $0,var}
awk读取一行后,getline 又读取了第二行
awk第三行, getline又读取了第四行。