Mitch Bailey
11/08/2020, 7:29 PM#! /bin/bash
awk '
/label/ {
label = $NF;
}
/^port/ {
print FILENAME, label, $2;
}
{
if ( last_file != $1 ) {
last_file = $1;
count = 1;
} else {
count = count + 1;
}
}' $* | \
sort -u -k1,1 -k3,3n | \
awk '
{
if ( last_file != $1 ) {
last_file = $1;
count = 1;
} else {
count = count + 1;
}
}
$NF != count {
print $0, count;
}'
I named it check_ports
and ran it as check_ports *.mag