Article 6EGSS when paste and join won't work

when paste and join won't work

by
atjurhs
from LinuxQuestions.org on (#6EGSS)
hi guys,

i'm trying to join the data inside two files. paste and join won't work because the number of rows in the two files is not the same, and the data is not in the same order in both files, and the data is not sorted. here's what the two files look like. the "key" used to join the two files is the numerical value in column two of both files
Code:bmc 3 ping
bmc 8 miss
bmc 1 miss
bmc 9 ping
bmc 10 ping
bmc 11 ping
bmc 12 pingfileB.dat
Code:id 3 1
id 7 1
id 4 1
id 8 0
id 8 0
id 1 0
id 9 1
id 10 1
id 10 1
id 11 1
id 12 1
id 13 1
id 14 1outFile.dat
Code:3 ping 1
8 miss 0
1 miss 0
9 ping 1
10 ping 1
11 ping 1
12 ping 1i'm a total hack but i'm trying here's what i've come up with so far, but of course it doesn't work
Code:awk -F'FNR==NR{if($2 == val){val2 = $2;nextfile};next}$3 == val2{sum++;print(val,$0)}' fileA.dat fileB.dat > outFile.datmaybe i should be doing a for loop?
can someone help me please, thank you!
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments