首页 > 系统服务 > 详细

shell入门-uniq去重复和tee

时间:2015-11-15 17:38:57      阅读:346      评论:0      收藏:0      [点我收藏+]

命令:uniq

选项:-c 显示重复数量

说明:去重复,不sort多个功能,显示几个重复

 

命令:tee

说明:重定向加上双重输出

 

 

[root@wangshaojun ~]# cat 2.txt
1
2
2
2
3
3
4
1
ac
5
[root@wangshaojun ~]# uniq 2.txt   ////消除顺序挨着的重复段

1
2
3
4
1
ac
5

///////////////////////////////////////////////////////////////////

-c

[root@wangshaojun ~]# uniq -c 2.txt
1 1
3 2
2 3
1 4
1 1
1 ac
1 5

//////////////////////////////////////////////////////////////////////

 先sort排序,然后uniq显示重复数量

[root@wangshaojun ~]# sort 2.txt |uniq -c
2 1
3 2
2 3
1 4
1 5
1 ac

 

//////////////////////////////////////////////////////////////////////////

tee

[root@wangshaojun ~]# echo "1111111" > 1.txt
[root@wangshaojun ~]# cat 1.txt
1111111
[root@wangshaojun ~]# echo "1111111" |tee 1.txt  ////输出内容显示在屏幕上
1111111

 

//////////////////////////////////////////////////////////////////////////////

总结:uniq -c  ////  sort 2.txt | uniq -c   /////    echo “111” |tee 1.txt

shell入门-uniq去重复和tee

原文:http://www.cnblogs.com/wangshaojun/p/4966752.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!