Like this, with one awk:
awk '$NF=="*"{$NF=""; arr[$0]++}END{for (i in arr) print i arr[i]}' ./*
$NFis the latest string separated by space(s) by default- the main trick is to create an associative named
array with the current words as key and incrementing as value - at the
ENDwe iterate over thearray toprinteach keys/values
With perl one-liner:
perl -anE '
if ($F[-1] eq "*") {
$k = join " ", @F[0..@F-2];
$a->{$k}++
}
END{say "$_ $a->{$_}" for keys %$a}
' ./*
The -a is the split mode in @F default array