• uniq 的作用是相邻行去重。

Shell脚本学习笔记——uniq


  • 常见选项

(1)-c 的作用是标识出重复行的重复次数。

Shell脚本学习笔记——uniq


(2)-d 表示只显示重复行。

Shell脚本学习笔记——uniq


(3)-u 表示只显示文件中不重复的各行。

Shell脚本学习笔记——uniq


  • 练习

结合sort、uniq工具,求file1 和 file2 的交集、并集和补集。file1 和 file2 的内容如下:

Shell脚本学习笔记——uniq

解题思路:将file1 和 file2 两个文件合并成一个文件进行操作。

Shell脚本学习笔记——uniq


Shell脚本学习笔记——uniq




相关文章: