this is a test
this is a test
this is a test
i am tank
i love tank
i love tank
this is a test
whom have a try
WhoM have a try
you have a try
i want to abroad
those are good men
we are good men
四,实例详解
代码如下:
[zhangy@BlackGhost mytest]$ uniq -c uniqtest
3 this is a test
1 i am tank
2 i love tank
1 this is a test //和第一行是重复的
1 whom have a try
1 WhoM have a try
1 you have a try
1 i want to abroad
1 those are good men
1 we are good men
[zhangy@BlackGhost mytest]$ sort uniqtest |uniq -c
1 WhoM have a try
1 i am tank
2 i love tank
1 i want to abroad
4 this is a test
1 those are good men
1 we are good men
1 whom have a try
1 you have a try
这样就可以解决上个例子中提到的问题
代码如下:
[zhangy@BlackGhost mytest]$ uniq -d -c uniqtest
3 this is a test
2 i love tank
uniq -d 只显示重复的行
代码如下:
[zhangy@BlackGhost mytest]$ uniq -D uniqtest
this is a test
this is a test
this is a test
i love tank
i love tank
uniq -D 只显示重复的行,并且把重复几行都显示出来。他不能和-c一起使用
代码如下:
[zhangy@BlackGhost mytest]$ uniq -f 1 -c uniqtest
3 this is a test
1 i am tank
2 i love tank
1 this is a test
2 whom have a try
1 you have a try
1 i want to abroad
2 those are good men //只有一行,显示二行
[zhangy@BlackGhost mytest]$ uniq -i -c uniqtest
3 this is a test
1 i am tank
2 i love tank
1 this is a test
2 whom have a try //一个大写,一个小写
1 you have a try
1 i want to abroad
1 those are good men
1 we are good men
检查的时候,不区分大小写
代码如下:
[zhangy@BlackGhost mytest]$ uniq -s 4 -c uniqtest
3 this is a test
1 i am tank
2 i love tank
1 this is a test
3 whom have a try //根上一个例子有什么不同
1 i want to abroad
1 those are good men
1 we are good men
检查的时候,不考虑前4个字符,这样whom have a try 就和 you have a try 就一样了。
代码如下:
[zhangy@BlackGhost mytest]$ uniq -u uniqtest
i am tank
this is a test
whom have a try
WhoM have a try
you have a try
i want to abroad
those are good men
we are good men
去重复的项,然后全部显示出来
代码如下:
[zhangy@BlackGhost mytest]$ uniq -w 2 -c uniqtest
3 this is a test
3 i am tank
1 this is a test
1 whom have a try
1 WhoM have a try
1 you have a try
1 i want to abroad
1 those are good men
1 we are good men