I have two files $A and $B
$A contains (the operator varies, it could be =, > or !=) Basically I have the awk command working as it should I just want to add the line from $A where it failed
number1 = 460
number2 = 12
number3 > 5
number4 > 20
number5 != 39
number6 != 0
$B contains
number1 453
number2 12
number3 7
number4 19
number5 39
number6 4
I have an awk command that compares two files and tells me if the numbers don't match
output=`awk '
{
getline buf <f2;
split( buf, a, " " );
if( $1 == a[1] && $2 == ">" && $3+0 > a[2]+0 )
printf( "%s\n", buf );
else if( $1 == a[1] && $2 == "!=" && $3+0 == a[2]+0 )
printf( "%s\n", buf );
else if( $1 == a[1] && $2 == "=" && $3+0 != a[2]+0 )
printf( "%s\n", buf );
}
' f2="$B" $A`
echo "$output"
number1 453
number4 19
number5 39
I am trying to get this output:
echo "$output"
This is the line that failed: number1 = 460 #coming from $A
This is the correct number: number1 453 #coming from $B
This is the line that failed: number4 > 20 #coming from $A
This is the correct number: number4 19 #coming from $B
This is the line that failed: number5 != 39 #coming from $A
This is the correct number: number5 39 #coming from $B