【问题标题】:check top 100 domains in email list检查电子邮件列表中的前 100 个域
【发布时间】:2018-09-30 12:23:33
【问题描述】:

我有一个很大的电子邮件列表,我想知道这个列表中的前 100 个域是什么,示例列表:

cristiano.ofidiani@libero.it
cristianocurzi70@libero.it
cristianogiustetto@libero.it
cristianopaolieri@fercart.com
cristianoristori@tiscali.it
cristianorollo@tiscali.it
cristianoscavi@alice.it
cristianotradigo@virgilio.it
cristianpassarelli@virgilio.it
cristianprisco@libero.it
cristianriparip@riparifranco.it
cristiansrl.pec@legalmail.it
cristina.arese@vestisolidale.it
cristina.armillotta@coldiretti.it
cristina.bazzi@bazzicroup.it
cristina.bedocchi@tin.it
cristina.benassi@terminalrubiero.com

我需要知道此列表中的顶级域,例如:

libero.it 100
tiscali.it 77
legalmain 44

我如何在 linux bash 中做到这一点?

【问题讨论】:

  • 查看cutsortuniq 的手册页
  • @Makoto 这里不需要复杂的bash 语法; @hhoke1 的回答显示了 54 个字符的简单管道。为此,最短的合理 Python 命令类似于print(Counter(x.split("@")[1] for x in stdin).most_common(100)),它忽略了使用Counterstdin 所必需的imports。这是 shell 和一些标准工具非常适合处理的任务。

标签: bash git-bash


【解决方案1】:

cut -d@ -f2 | sort | uniq -c | sort -nr | head -n 100 应该可以解决问题。 cut 提取域,使用@分隔字段,uniq 需要排序列表,-c 给出计数,sort -nr 以降序排列,head 给出前一百位。

【讨论】:

    猜你喜欢
    • 2022-06-16
    • 1970-01-01
    • 2013-09-06
    • 1970-01-01
    • 2022-12-10
    • 2019-02-07
    • 2013-10-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多