Skip to content

Instantly share code, notes, and snippets.

@kitelife
Created May 11, 2016 16:07
Show Gist options
  • Save kitelife/a148f3e52780109abbb7aa2352d8f0a5 to your computer and use it in GitHub Desktop.
Save kitelife/a148f3e52780109abbb7aa2352d8f0a5 to your computer and use it in GitHub Desktop.
cat words.txt | sort | uniq -c | sort -k1,1nr | head -10
/*
sort: 对单词进行排序
uniq -c: 显示唯一的行,并在每行行首加上本行在文件中出现的次数
sort -k1,1nr: 按照第一个字段,数值排序,且为逆序
head -10: 取前10行数据
*/
cat filter.log | awk -F '[' '{print $4}' | awk -F ':' '{print $1}' | sort | uniq -c | sort -k1,1nr | head -10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment