给出一个/ var / log / messages文件,记录不同的用户发送电子邮件记录,例如:
20140912 chris sendingemails_id00012jjdi3x
20140912 chris sendingemails_id00012jjdiji
20140912 alen sendingemails_id00012jwciscl
20140914 chris sendingemails_id00012jjdiji
20140915 linda sendingemails_id042555jwciscl
20140915 chris sendingemails_id00012jjdiji
20140916 alen sendingemails_id005hhbxxsscl
20140917 chris sendingemails_id2221d2rwaaiji
20140917 linda sendingemails_id00012baseeqcl
20140918 chris sendingemails_id45677tehhwaaiji
现在,我需要检索发送电子邮件最多的用户。我该怎么做? 非常感谢。
答案 0 :(得分:0)
这应该有所帮助:
cat /var/log/messages | grep "sendingemails_" | awk '{print $2}' | sort | uniq -c
或者获取用户名:
cat /var/log/messaes | grep "sendingemails_" | awk '{print $2}' | sort | uniq -c | sort -r | head -1 | awk '{print $2}'