Hello,
I am having a disconcerting problem regarding awk. I am trying to read certain lines from a data file. The line numbers which I am reading are stored in a separate file.
Code:
BEGIN {
file1 = "extract_t0.0500.dat"
i = 29
}
{
for (j=1;j<i;j++) {
file_in = "pointlist_x"bin[j]".txt"
while ((getline < file_in) > 0) {
command = "tail +"$1" " file1 " | head -1"
print command
command | getline
print $1 " " NF
printf("%5.4f \t%5.4f\n",$5,$7)
}
}
}
Note that "pointlist_x*.txt" are files with a single column of integers that correspond to the line numbers that I want to read in file1. The output of this script gives, for example:
Code:
tail +1050 extract_t0.0500.dat | head -1
(The output of the printf statement is a blank line, or null string.) Now, if I run the command
Code:
tail +1050 extract_t0.0500.dat | head -1 | awk '{printf("%5.4f \t%5.4f\n",$5,$7)}'
in the shell, I get floating point values as I expect.
Can someone explain why getline is behaving oddly in this situation?
Thanks in advance for the help.