I'm stumbling over myself trying to get a seemingly simple thing accomplished. I have one file, and one newline delimited string list.
File:
Dat1 Loc1
Dat2 Loc1
Dat3 Loc1
Dat4 Loc2
Dat5 Loc2
My list is something like this:
Dat1
Dat2
Dat3
Dat4
What I am trying to do is compare the list with the data file and count the number of unique Locs that appear. I am interested only in the largest count. In the example above, when comparing the list to the file, I want essentially:
Dat1 MATCHED Loc1Count = 1
Dat2 MATCHED Loc1Count = 2
Dat3 MATCHED Loc1Count = 3
Dat4 MATCHED Loc2Count = 1
Return: Loc1 if Loc1Count/Length of List > 50%
Now,
I know that awk 1 file will read a file line by line. Furthermore I know that "echo "$LIST" | awk '/search for a line that contains this/" will return the line that matches that internal string. I haven't been able to combine these ideas successfully though as nested awks, much less how to count "loc1" vs "loc2" (which, by the way, are going to be random strings, and not form-standard)
I feel like this is simple, but I'm banging my head against a wall. Any ideas? Is this sufficiently clear?