您的位置:首页 > 运维架构 > Shell

shell入门-uniq去重复和tee重定向

2015-11-15 16:12 183 查看
命令: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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: