|
From: | Dial, Mary |
Subject: | [bug-gawk] gawk simple compare not working? |
Date: | Tue, 31 Mar 2015 17:08:08 +0000 |
I’m stumped! Any help is appreciated. I run this simple gawk compare program (below) and it does not return the correct answer. But if a append an ‘x’ to the compare, then it works. Im not sure if this is an gawk bug. I’m using Red Hat Linux 6.6. Both gawk 3.7.1 and 4.1 return the same results Here is the sample input where the 2nd to last characters are different File c1 073343000773200000000075 File c2 073343000773200000000005 Here is the run test run gawk_test_diff c1 c2 Straight Compare - Lines are the same Add Char Compare - Lines are different Here is the gawk program gawk_test_diff #!/bin/ksh old_file=${1} current_file=${2} gawk -v oldfile=${old_file} \ -v currentfile=${current_file} \ 'BEGIN {
# Get a line from the old file ofile=getline oldline < oldfile
# Get a line from the current file cfile=getline currentline < currentfile
# While not EOF old or current file while ( ofile > 0 || cfile > 0 ) {
# if not EOF old and current file
if (ofile > 0 && cfile > 0 ) {
# Compare lines
if (oldline != currentline) { printf("Straight Compare - Lines are different \n") } else printf("Straight Compare - Lines are the same\n") # Compare lines and add a character if ("x"oldline != "x"currentline) { printf("Add Char Compare - Lines are different \n") } else printf("Add Char Compare - Lines are the same\n") # Get another line from the old file ofile=getline oldline < oldfile
# Get another line from the current file cfile=getline currentline < currentfile
}
}
close(oldfile)
close(currentfile)
}'
exit 0 ---- This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify FDB Support (address@hidden) immediately by e-mail and delete the original message. ---------------------------------------------------------------------- |
[Prev in Thread] | Current Thread | [Next in Thread] |