Вот чисто POSIX awk
решение (с sort
вызывается из внутри awk
prog баран):
awk -F. -v OFS='\t' '
# Build an associative array that maps each unique top-level domain
# (taken from the last `.`-separated field, `$NF`) to how often it
# occurs in the input.
{ a[$NF]++ }
END {
# Print the header.
print "Domain Name", "No of Email"
print "----------------------------"
# Output the associative array and sort it (by top-level domain).
for (k in a) print k, a[k] | "sort"
}
' file
Если у вас есть GNU awk 4.0
или выше, вы можете обойтись без внешнего sort
и даже легко контролировать поле сортировки внутри программы gawk
:
gawk -F. -v OFS='\t' '
# Build an associative array that maps each unique top-level domain
# (taken from the last `.`-separated field, `$NF`) to how often it
# occurs in the input.
{ a[$NF]++ }
END {
# Print the header.
print "Domain Name", "No of Email"
print "----------------------------"
# Output the associative array and sort it (by top-level domain).
# First, control output sorting by setting the order in which
# the associative array will be looped over by, via the special
# PROCINFO["sorted_in"] variable; e.g.:
# - Sort by top-level domain, ascending: "@ind_str_asc"
# - Sort by occurrence count, descending: "@val_num_desc"
PROCINFO["sorted_in"]="@ind_str_asc"
for (k in a) print k, a[k]
}
' file
Есть ли у этих лиц одобрите ваше размещение своих адресов здесь, в ясном виде? – tripleee
@tripleee: Хотя они _look_, как настоящие адреса электронной почты, похоже, что они не являются (по крайней мере, согласно http://verify-email.org/). – mklement0
Я бы не стал доверять этому инструменту. Все это показывает, что они отключили эту распространенную технику спамера на своих серверах. – tripleee