Solved comparing two files in awk

April 9, 2013 at 09:30:15
Specs: Solaris 10 10/08, T5240
Hi Guys,

I would like to compare two files using awk and shows only the registers that has not found in file2.

These files have millions of registers.

For example:

# cat test.txt
a
b
c
d

# cat test1.txt
a
b
d

So, i need that the output be "c"

Does anyone know how can i do it using awk ?



See More: comparing two files in awk

Report •


#1
April 9, 2013 at 13:53:47
✔ Best Answer
#!/bin/ksh

# solaris
nawk ' BEGIN {
   while ( getline < "test1.txt" > 0 )
      s[$0]=$0
}
{
if($0 in s)
  x=1
else
  print $0

} ' test.txt


Report •
Related Solutions


Ask Question