1

I have a list of mac addresses of machines by means of a dhcp log. I need to filter on a set of mac address prefixes (the substring) which belong to a vendor. How can I can filter the list of machine mac addresses based on the set of vendor prefixes?

1 Answer 1

1

You can use the following construct, assuming the mac addresses are normalized, i.e., both files are using a unique separator like a colon or dash:

$ grep -Ff file-with-prefixes file-with-machine-mac-addresses

This might or might not adhere to your semantics of a "relaxed" intersection.

/Updated to use grep -F based on @wildcard's comment.

1
  • 1
    May want to add the -F flag for fixed string search if you happen to be using periods for separators (which I suppose should be unlikely). Alternatively, you could add a ^ at the beginning of each line of the prefixes file to avoid matching suffixes or arbitrary substrings.
    – Wildcard
    Nov 25, 2016 at 13:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .