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 = 100
$B contains
number1 453 number2 100
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" number 453
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
Note that the operators might change to > or < so its important that the output comes from the file
https://stackoverflow.com/questions/66990068/using-printf-in-awk April 08, 2021 at 12:19AM
没有评论:
发表评论