My suggestion would be something like this:
awk '(NR==FNR){a[$1]=$0;next}
($1 in a){delete a[$1]}
END{for(i in a) print a[i]}' file_a file_b file_c ...
Here we assumed that the key in all files is $1
(i.e. the mac-address). The code works in the following way:
(NR==FNR){a[$1]=$0;next}
: when reading the first file (file A), store its records/lines in an array indexed by the mac address located in field 1. Use next
to skip any further processing and move to the next record/line.
($1 in a){delete a[$1]}
: for any other file, check if the key (mac address) is part of the array a. If it is, it means we can remove it from the array, as we are not interested in it.
END{for(i in a) print a[i]}
: at the end, when all files are processed, check which mac addresses are still available in in the array. This means these are the arrays which are in file a but not in any of the other files. Print them. (be aware, they will not be printed in the same order of file a)
If $1
is not always the key, but each line has one mac-address somewhere, we can pick it up with a regex:
awk 'BEGIN{ere_mac = "[0-9A-Fa-f][0-9A-Fa-f][-:]"
ere_mac = ere_mac ere_mac ere_mac ere_mac ere_mac;
ere_mac = ere_mac "[0-9A-Fa-f][0-9A-Fa-f]"}
{ match($0,ere_mac); key=substr($0,RSTART,RLENGTH)}
(NR==FNR) { a[key]=$0 }
(key in a) { delete a[key] }
END { for(i in a) print a[i] }' file_a file_b file_c ...
note: this is a very complicated way to build ere_mac
, but it works if your awk does not accept grouping and repetitions. otherwise use ere_mac=([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})
A complete alternative and more simple way would be:
grep -vFf <(awk '{print $1}' file_b file_c ...) file_a