Hi,
I am trying to compare two files so I can identify the common, unique-to-file1, and unique-to-file2 records. Details are as follows:
file1.in
0
1
2
===============
file2.in
A
B
C
=================
The awk code is as follows
BEGIN { file2 = ARGV[2]; }
{
mac_1 = $0
print mac_1
while ( ( getline mac_2 < file2 ) > 0)
{
print mac_2;
}
print "============"
}
END { close("file2.in")}
============================
Execution:
nawk -f compare_multiple_files.awk file1.in file2.in
===============================
Output:
In my mind, for every one iteration of the outer loop, the utility should go through the entire inner loop. However the reality is different. Output is as follows
0
A
B
C
============
1 <--------- Why did we not iterate through all of the inner loop ???
============
2
============
A
============
B
============
C
============
Any debugging help or a new (effecient) approach will be appreciated.
Thanks in advance.
roger42
I am trying to compare two files so I can identify the common, unique-to-file1, and unique-to-file2 records. Details are as follows:
file1.in
0
1
2
===============
file2.in
A
B
C
=================
The awk code is as follows
BEGIN { file2 = ARGV[2]; }
{
mac_1 = $0
print mac_1
while ( ( getline mac_2 < file2 ) > 0)
{
print mac_2;
}
print "============"
}
END { close("file2.in")}
============================
Execution:
nawk -f compare_multiple_files.awk file1.in file2.in
===============================
Output:
In my mind, for every one iteration of the outer loop, the utility should go through the entire inner loop. However the reality is different. Output is as follows
0
A
B
C
============
1 <--------- Why did we not iterate through all of the inner loop ???
============
2
============
A
============
B
============
C
============
Any debugging help or a new (effecient) approach will be appreciated.
Thanks in advance.
roger42