The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 03-29-2008
radoulov's Avatar
radoulov radoulov is offline
addict
 

Join Date: Jan 2007
Location: Milan, Italy/Varna, Bulgaria
Posts: 1,542
Code:
awk 'END { for (k in f2) {
    split(f2[k], t)
    print f2[k] > (((t[1] SUBSEP t[2] SUBSEP t[3]) in f1) ? "file5" : "file6")
    }
}
NR == FNR { 
f2[$1,$2,$3] = $0
next 
}
($1 SUBSEP $2 SUBSEP $3) in f2 { 
print > "file3" 
f1[$1,$2,$3] = $0 
next 
}
{ print > "file4" }
' file2 file1
Use nawk or /usr/xpg4/bin/awk on Solaris.
Reply With Quote