我有以下每个月每天的 csv 文件。我需要从中获取用户的唯一计数。我们需要每月计数。
"DATE","TIME","User Type","User ID","IP Address","Host Name"
"2019-06-01","00:02:08,278","User","uid=robot_th,ou=people,o=kpno,c=be","10.120.134.13","10.120.134.13"
"2019-06-01","00:02:08,918","User","uid=robot_th,ou=people,o=kpno,c=be","10.120.134.13","10.120.134.13"
"2019-06-01","00:03:16,143","User","uid=josebeco,ou=people,o=kpno,c=be","10.121.21.98","10.121.21.98"
"2019-06-01","00:05:14,314","User","uid=josebeco,ou=people,o=kpno,c=be","10.121.21.107","10.121.21.107"
"2019-06-01","00:06:34,080","User","uid=robot_sebeco,ou=people,o=kpno,c=be","10.121.21.107","10.121.21.107"
"2019-06-01","00:16:54,981","User","uid=robot_sebeco,ou=people,o=kpno,c=be","10.121.21.98","10.121.21.98"
"2019-06-01","00:16:55,575","User","uid=robot_sebeco,ou=people,o=kpno,c=be","10.121.21.98","10.121.21.98"
"2019-06-01","00:17:26,344","User","uid=jolivier,ou=people,o=kpno,c=be","10.120.134.13","10.120.134.13"
"2019-06-01","00:17:30,994","User","uid=robot_th,ou=people,o=kpno,c=be","10.120.134.13","10.120.134.13"
"2019-06-01","00:18:16,914","User","uid=robot_sebeco,ou=people,o=kpno,c=be","10.121.21.98","10.121.21.98"
"2019-06-01","00:31:48,322","User","uid=josebeco,ou=people,o=kpno,c=be","10.121.21.98","10.121.21.98"
"2019-06-01","00:32:25,260","User","uid=robot_th,ou=people,o=kpno,c=be","10.120.134.13","10.120.134.13"
"2019-06-01","00:32:57,631","User","uid=josebeco,ou=people,o=kpno,c=be","10.121.21.98","10.121.21.98"
"2019-06-01","00:35:11,292","User","uid=josebeco,ou=people,o=kpno,c=be","10.121.21.107","10.121.21.107"
"2019-06-01","00:46:58,693","User","uid=robot_sebeco,ou=people,o=kpno,c=be","10.121.21.98","10.121.21.98"
"2019-06-01","00:47:01,215","User","uid=robot_th,ou=people,o=kpno,c=be","10.120.134.13","10.120.134.13"
答案1
在磨坊主,你可以运行
mlr --csv count-distinct -f "User ID" input.csv
具有
+----------------------------------------+-------+
| User ID | count |
+----------------------------------------+-------+
| uid=robot_th,ou=people,o=kpno,c=be | 5 |
| uid=josebeco,ou=people,o=kpno,c=be | 5 |
| uid=robot_sebeco,ou=people,o=kpno,c=be | 5 |
| uid=jolivier,ou=people,o=kpno,c=be | 1 |
+----------------------------------------+-------+