#!/bin/sh
(parallel notmuch address {} "\*'$1'\*" ::: \
'--output=sender' '--output=recipients') | \
grep -Pi "$1" | \
awk '
/@/ {
s=$NF;
sub(/^</, "", s);
sub(/>$/, "", s);
printf("%s\t", s);
for (i = 1; i < NF; i++)
printf("%s ", $i);
printf("\n")
}
' | sort -u -k 1,1 | uniq -c | sort -nr | cut -c6- | awk 'BEGIN{print}{print $0}'