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
选项:-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
相关文章推荐
- 将DOS批处理文件转换为Shell脚本
- 将DOS批处理文件转换为Shell脚本
- shell入门-wc
- shell入门-sort排序
- shell入门-cut命令
- shell入门-特殊符号
- shell常用命令
- shell-bash学习03 别名、日期、函数
- shell编程笔记
- shell读取文件每一行的方式
- xshell 登陆 ubuntu
- linux shell 管道命令(pipe)使用及shell重定向
- Xshell的使用
- Shell Game
- 让shell脚本在后台飞
- LinuxShell算术运算
- 如何在 Bash 中删除“除某些文件外的所有文件”?
- 正则表达式shell
- shell根据日期实现完全备和增量备份文件
- shell 自动发送邮件脚本