I am using
grep -o <string> <filename> | wc -l
to count the number of times <string>
occurs in the file. I now need to extend this such that the string is from a list of items in another file.
The objective being to count the occurrences of each line of the 'string' file in the main file. The string file will be a list of VLANs and the main file(s) an output of the MAC address list of a large LAN Switch.
String file is in the format...
100
101
103
110
230
(Note spaces are in place before and after the numbers to cover off the string matching larger numbers and being found in other data (see below).
The files being checked against have lines in the format...
6c4b-904b-0c5c 230 Learned BAGG103 Y
I am ultimately looking to...
- Count the number of occurences of the string in the first file in the second, matches are expected against the second column
- Highlight any situations where the string does not match with the string listed
Edit - I think I have the first question answered but can't cover off listing the VLANs that aren't found.