命令 : uniq
去重复的行,最常用的选项只有一个:
-c :统计重复的行数,并把行数写在前面
[root@localhost ~]# vim testb.txt
把下面的内容写入testb.txt, 保存。
111 222 111 333
使用uniq 的前提是需要先给文件排序,否则不管用。
[root@localhost ~]# uniq testb.txt 111 222 111 333 [root@localhost ~]# sort testb.txt |uniq 111 222 333 [root@localhost ~]# sort testb.txt |uniq -c 2 111 1 222 1 333
命令 : tee
后跟文件名,类似与重定向 “>”, 但是比重定向多了一个功能,在把文件写入后面所跟的文件中的同时,还显示在屏幕上。但是不支持错误写入。
[root@localhost ~]# echo "aaaaaaaaaaaaaaaaaaaaaaaaaaa" |tee testb.txt aaaaaaaaaaaaaaaaaaaaaaaaaaa [root@localhost ~]# cat testb.txt aaaaaaaaaaaaaaaaaaaaaaaaaaa
tee 常用于管道符 “|” 后。