Article 5EEVW How can I use awk to count matched lines

How can I use awk to count matched lines

by
DV100
from LinuxQuestions.org on (#5EEVW)
greeting

Someone wrote this code on stackoverflow. The code works but I need to know how to add a count for matched lines and which line in a.txt found the match.

Contents of a.txt

01 02 03 04
11 12 13 14
04 02 03 01
19 20 21 25
11 15 39 01

Contents of b.txt

01 02 03 04 05
11 15 33 31 12
01 02 05 25 17
03 02 01 04 21

The Code

Code:#!/bin/bash

awk 'NR==FNR { a[++n] = $1; b[n] = $2; c[n] = $3; d[n] = $4; next }
{ for (i=1; i<=n; ++i)
if ($0 ~ a[i] && $0 ~ b[i] && $0 ~ c[i] && $0 ~ d[i]) {
print; break }
}' a.txt b.txtThe output of script
Code:$ awk-testmatch
01 02 03 04 05
03 02 01 04 21
How can I count the matches made, eg. 2 in above and which line in a.txt file
did the match?

I appreciate any help or suggestions, Thankslatest?d=yIl2AUoC8zA latest?i=ziIN8y0948k:EXODEhCi8sc:F7zBnMy latest?i=ziIN8y0948k:EXODEhCi8sc:V_sGLiP latest?d=qj6IDK7rITs latest?i=ziIN8y0948k:EXODEhCi8sc:gIN9vFwziIN8y0948k
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