Tente.
awk 'NR==FNR{seen[$0];next}{x="echo " $0 "|md5sum| cut -d- -f1|cut -f1 ";
x|getline l;close(x);md5[l]=$0}
END{for (M in md5) {chk=md5[M];gsub (" ", "", M);for (U in seen) if(M==U){print M, chk}}
}' file1 file2
Entradas:
==> file1 <==
5ca4136a060a2574a936cdf6881f733c
8068123f8384b305d133add978a3c12c
96653200bf87722738bc4abf7b3d5589
731a1f0a260d40c758aa18237de3fe6c
==> file2 <==
[email protected]
[email protected]
UNIX.stackexchange.com
STACKECHANGE.COM
Saída (os endereços de e-mail cujo hash foi visto no arquivo1):
731a1f0a260d40c758aa18237de3fe6c UNIX.stackexchange.com
96653200bf87722738bc4abf7b3d5589 [email protected]
Usar grep
é muito fácil.
grep -Ff file1 \
<(awk '{x="echo " $0 "|md5sum| cut -d- -f1"; x|getline l;print l, $0}' file2)
96653200bf87722738bc4abf7b3d5589 [email protected]
731a1f0a260d40c758aa18237de3fe6c UNIX.stackexchange.com