软件测试学习笔记丨 Linux 命令 uniq 去重
作者:测试人
- 2024-01-29 北京
本文字数:1338 字
阅读完需:约 4 分钟
素材(统计 IP 出现次数)
[ck289433@shell.ceshiren.com test]$ cat uniq_demo.txt
ck141906 pts/0 120.52.147.49
ck140081 pts/13 113.65.231.23
ck140081 pts/12 113.65.231.23
ck140081 pts/4 221.219.101.182
82894931 pts/12 36.112.85.179
18221511 pts/10 223.71.133.42
18221511 pts/2 223.71.133.42
68821400 pts/4 183.63.81.211
18221511 pts/5 223.71.133.42
04300137 pts/0 223.104.212.185
root pts/10 223.71.133.42
18221511 pts/5 223.71.133.42
18221511 pts/4 223.71.133.42
16210504 pts/3 58.33.96.123
xly20456 pts/2 120.52.147.46
ck146119 pts/2 116.237.250.188
ck143117 pts/11 60.208.90.202
ck146119 pts/11 116.237.250.188
ck146119 pts/10 116.237.250.188
70146364 pts/2 106.39.114.134
13863896 pts/9 183.6.105.176
root pts/5 223.71.133.42
18221511 pts/3 223.71.133.42
18221511 pts/9 223.71.133.42
ck153117 pts/5 60.208.90.202
50153372 pts/4 223.104.148.19
ck153117 pts/3 60.208.90.202
18221511 pts/9 223.71.133.42
root pts/5 223.71.133.42
root pts/4 223.71.133.42
18221511 pts/3 223.71.133.42
ck146400 pts/2 112.10.50.241
ck148853 pts/5 219.137.140.149
95015293 pts/9 36.113.11.39
ck141731 pts/14 61.140.133.96
21609891 pts/12 101.230.255.202
95015293 pts/11 36.113.11.39
21609891 pts/10 58.35.66.243
21609891 pts/9 101.230.255.202
21609891 pts/4 101.230.255.202
ck148853 pts/3 119.131.106.44
21609891 pts/5 101.230.255.202
ck141731 pts/2 61.140.133.96
21609891 pts/4 58.35.66.243
21609891 pts/3 58.35.66.243
ck141731 pts/2 61.140.133.96
68949047 pts/13 183.228.90.226
ck144530 pts/10 116.233.212.19
ck153117 pts/3 60.208.90.202
ck146264 pts/0 111.23.244.189
ck153307 pts/12 119.253.43.100
ck143117 pts/12 221.219.101.182
root pts/3 223.71.133.42
50153372 pts/11 117.136.68.46
ck153307 pts/10 119.253.43.100
ck144530 pts/4 116.233.212.19
70146364 pts/10 106.39.114.134
70146364 pts/4 106.39.114.134
26611853 pts/2 111.197.21.141
12221712 pts/0 101.228.81.73
18760789 pts/0 1.95.141.31
ck140752 pts/2 111.202.144.35
ck140752 pts/10 111.202.144.35
ck155454 pts/1 117.149.23.194
81368355 pts/5 220.249.55.194
ck151573 pts/9 124.74.76.126
04300137 pts/5 180.168.96.174
68949047 pts/3 183.228.90.226
08036051 pts/2 182.138.102.27
ck146400 pts/1 112.10.50.241
dx371407 pts/0 111.196.166.76
复制代码
1. 跳过前 N 项-f,对第 N+1 项去重
注意:只有挨在一起的内容会进行去重
uniq -f 2 uniq_demo.txt
复制代码
2. 先排序,再去重,最后加统计-c
cat uniq_demo.txt | sort -k 3 | uniq -f 2 -c
复制代码
3. 再对上一步结果按照出现次数的倒序排列
cat uniq_demo.txt | sort -k 3 | uniq -f 2 -c | sort -nr
复制代码
霍格沃兹的测试管理班是专门面向测试与质量管理人员的一门课程,通过提升从业人员的团队管理、项目管理、绩效管理、沟通管理等方面的能力,使测试管理人员可以更好的带领团队、项目以及公司获得更快的成长。提供 1v1 私教指导,BAT 级别的测试管理大咖量身打造职业规划。
划线
评论
复制
发布于: 刚刚阅读数: 5
测试人
关注
专注于软件测试开发 2022-08-29 加入
霍格沃兹测试开发学社,测试人社区:https://ceshiren.com/t/topic/22284
评论