I have a file which has the patterns that I have to find in the given data set and add the numbers in a columns of the data. I want to write a script or use awk/sed/grep to automatically query the patterns in a given file to cross check with the data I have and to add the numbers in the columns with matching pattern.
Example:-Example:-
Data
TITLE,COUNT,RESA
10th ECOMF,PAB 1 MAT
10th ICOCPS (CPV-'10) 23 SCI
10th ICOCPS (CPV-'10) 6 SCI
10th ICOMAMOS (M2S-X) 3 EEE
JOP 32 COP
AIP 34 Sff
JOP 43 COP
HIT 42 tilde
10th ECOMF,PAB 1 MAT 10th ICOCPS (CPV-'10) 23 SCI 10th ICOCPS (CPV-'10) 6 SCI 10th ICOMAMOS (M2S-X) 3 EEE JOP 32 COP AIP 34 Sff JOP 43 COP HIT 42 tilde My pattern file consists names of the journals:-
10th ECOMF,PAB
10th ICOCPS (CPV-'10)
10th ICOCPS (CPV-'10)
10th ICOMAMOS (M2S-X)
JOP
AIP
JOP
HIT
SUPERCONDUCTIVITY (M2S-X)
10th ECOMF,PAB 10th ICOCPS (CPV-'10) 10th ICOCPS (CPV-'10) 10th ICOMAMOS (M2S-X) JOP AIP JOP HIT SUPERCONDUCTIVITY (M2S-X) Desired output:
10th ECOMF,PAB 1
10th ICOCPS (CPV-'10) 29
10th ICOMAMOS (M2S-X) 3
JOP 75
AIP 34
HIT 42
.
.
10th ECOMF,PAB 1 10th ICOCPS (CPV-'10) 29 10th ICOMAMOS (M2S-X) 3 JOP 75 AIP 34 HIT 42 . . so on,
PS:- Data is Tab-separated, I same data in CSV too.