Best way to simulate “group by” from bash?

前端 未结 14 1081
半阙折子戏
半阙折子戏 2020-11-29 15:03

Suppose you have a file that contains IP addresses, one address in each line:

10.0.10.1
10.0.10.1
10.0.10.3
10.0.10.2
10.0.10.1

You need a

14条回答
  •  心在旅途
    2020-11-29 16:03

    Solution ( group by like mysql)

    grep -ioh "facebook\|xing\|linkedin\|googleplus" access-log.txt | sort | uniq -c | sort -n
    

    Result

    3249  googleplus
    4211 linkedin
    5212 xing
    7928 facebook
    

提交回复
热议问题