I have 2 files
cat file1.txt
lspol > 8296
....
cat file2.txt
lspol 8297
...
I am trying to get output if the number for column 1 in file2.txt is greater than number in for column 1 in file1.txt
The command below works great
# if column 1 of file1.txt is equal to column 1 of file2.txt and column 3 of file1.txt is greater than column 2 in file2.txt
awk '
{
getline buf <f2;
split( buf, a, " " );
if( $1 == a[1] && $3+0 > a[2]+0 )
printf( "%s\n", buf );
}
' f2="file2.txt" file1.txt
I am trying to pull the operator from 2nd column in file1.txt but no luck. I have tried many ways and here is one of them
awk '
{
getline buf <f2;
split( buf, a, " " );
if( $1 == a[1] && $3+0 $2 a[2]+0 )
printf( "%s\n", buf );
}
' f2="file2.txt" file1.txt